Darren Duncan > Muldis-D-0.30.0 > Muldis::D::Core::Types

Download:
Muldis-D-0.30.0.tar.gz

Annotate this POD

CPAN RT

Open  0
Report a bug
Source   Latest Release: Muldis-D-0.99.0

NAME ^

Muldis::D::Core::Types - Muldis D general purpose data types

VERSION ^

This document is Muldis::D::Core::Types version 0.23.1.

PREFACE ^

This document is part of the Muldis D language specification, whose root document is Muldis::D; you should read that root document before you read this one, which provides subservient details. Moreover, you should read the Muldis::D::Core document before this current document, as that forms its own tree beneath a root document branch.

DESCRIPTION ^

This document contains one or more sections that were moved here from Muldis::D::Core so that that other document would not be too large.

TYPE SUMMARY ^

Following are all the data types and data type factories described in this document, arranged in a type graph according to their proper sub|supertype relationships:

    sys.std.Core.Type.Universal

        sys.std.Core.Type.Empty

        sys.std.Core.Type.Scalar

            # The following are all regular ordered scalar types.

            sys.std.Core.Type.Bool
            sys.std.Core.Type.Int
                sys.std.Core.Type.UInt
                    sys.std.Core.Type.PInt
            sys.std.Core.Type.Blob
            sys.std.Core.Type.Text

        # The following are mostly nonscalar type factories.

        sys.std.Core.Type.Tuple
            sys.std.Core.Type.TupleD0
            sys.std.Core.Type.Database

        sys.std.Core.Type.Relation
            sys.std.Core.Type.RelationD0
            sys.std.Core.Type.Set
                sys.std.Core.Type.Maybe
                    sys.std.Core.Type.Nothing
                    sys.std.Core.Type.Single
            sys.std.Core.Type.Seq
            sys.std.Core.Type.Bag

        # The following is filler, to group possible user-def types.

        sys.std.Core.Type.QuasiScalar
            sys.std.Core.Type.QuasiScalarDVPT

        # The following are mostly quasi-nonscalar type factories.

        sys.std.Core.Type.QuasiTuple
            sys.std.Core.Type.QuasiTupleD0

        sys.std.Core.Type.QuasiRelation
            sys.std.Core.Type.QuasiRelationD0
            sys.std.Core.Type.QuasiSet
                sys.std.Core.Type.QuasiMaybe
                    sys.std.Core.Type.QuasiNothing
                    sys.std.Core.Type.QuasiSingle
            sys.std.Core.Type.QuasiSeq
            sys.std.Core.Type.QuasiBag

        # The following are all remnant types.

        sys.std.Core.Type.Remnant
            sys.std.Core.Type.ScaTupRel

Note that sys.std.Core.Type.Empty is a proper subtype of all of the other types in this graph, but every other type has only one immediate supertype shown, and hence the graph of them is a simple hierarchy.

SYSTEM-DEFINED CORE MAXIMAL AND MINIMAL DATA TYPES ^

These core data types are special and are the only Muldis D types that are neither scalar nor nonscalar nor quasi-nonscalar types. They are all system-defined and it is impossible for users to define more types of this nature.

sys.std.Core.Type.Universal

The Universal type is the maximal type of the entire Muldis D type system, and contains every value that can possibly exist. Every other type is implicitly a proper subtype of Universal, and Universal is implicitly a union type over all other types. Its default value is Bool:false. The cardinality of this type is infinity.

sys.std.Core.Type.Empty

The Empty type is the minimal type of the entire Muldis D type system, and is the only type that contains exactly zero values. Every other type is implicitly a proper supertype of Empty and Empty is implicitly an intersection type over all other types. It has no default value. The cardinality of this type is zero.

SYSTEM-DEFINED CORE SCALAR DATA TYPES ^

These core scalar data types are the most fundamental Muldis D types. Each one has zero possreps, and hence has no named components that can be referenced. Plain Text Muldis D provides a specific syntax per type to select a value of one of these types, which does not look like a routine invocation, but rather like a scalar literal in a typical programming language; details of that syntax are not given here, but in Muldis::D::Dialect::PTMD_Tiny. Hosted Data Muldis D as hosted in another language will essentially use literals of corresponding host language types, whatever they use for eg booleans and integers and character strings, but tagged with extra meta-data if the host language is more weakly typed or lacks one-to-one type correspondence; see Muldis::D::Dialect::HDMD_Perl_Tiny for a Perl-based example. These types are all ordered.

sys.std.Core.Type.Scalar

The Scalar type is the maximal type of all Muldis D scalar types, and contains every scalar value that can possibly exist. Every other scalar type is implicitly a proper subtype of Scalar, and Scalar is implicitly a union type over all other scalar types. Its default value is Bool:false. The cardinality of this type is infinity.

sys.std.Core.Type.Bool

A Bool is a scalar enumeration consisting of the 2 values Bool:false and Bool:true. It represents a truth value, and is the result type of any is_identical or is_not_identical routine; it is the only essential general-purpose scalar data type of a D language. Its default and minimum value is Bool:false; its maximum value is Bool:true. The cardinality of this type is 2.

sys.std.Core.Type.Int

An Int is a single exact integral number of any magnitude. Its default value is zero; its minimum and maximum values are conceptually infinities and practically impossible. The cardinality of this type is infinity; to define a most-generalized finite Int subtype, you must specify the 2 integer end-points of the inclusive range that all its values are in.

sys.std.Core.Type.UInt

A UInt (unsigned / non-negative integer) is a proper subtype of Int where all member values are greater than or equal to zero. Its minimum value is zero.

sys.std.Core.Type.PInt

A PInt (positive integer) is a proper subtype of UInt where all member values are greater than zero. Its default and minimum value is 1.

sys.std.Core.Type.Blob

A Blob is an undifferentiated string of bits. Its default and minimum value is the empty string; its maximum value is an infinite-length string and practically impossible. The cardinality of this type is infinity; to define a most-generalized finite Blob subtype, you must specify a maximum length in bits that the subtype's strings are.

sys.std.Core.Type.Text

A Text is a string of characters. Its default and minimum value is the empty string; its maximum value is an infinite-length string and practically impossible. Note that there is only one system-defined character repertoire for Text types, which is the newest Unicode repertoire (5.0.0). The cardinality of this type is infinity; to define a most-generalized finite Text subtype, you must specify a maximum length in characters (that is, eg, in NFC graphemes) that the subtype's strings are.

SYSTEM-DEFINED CORE NONSCALAR PARAMETERIZED DATA TYPES ^

These are only called nonscalar data types in a loose sense, because by themselves they are incomplete type definitions. Actual nonscalar data type definitions are derived from these by supplying the balance of the type definitions, such as what their attributes are and/or what their attribute types are. Associated with these incomplete type definitions are a set of system-defined routines that can be applied to values of any actual nonscalar types derived from them; such are called generic nonscalar operators. In the Muldis D type system, these incomplete nonscalar types are defined as union types over all actual types derived from them, and are proper supertypes of said.

Some actual nonscalar data types are system-defined, for use in defining the Muldis D system catalog / meta-model (see further below in the current document), and some others are system-defined for convenience since they are the types of many core operators (see further below in the current document), but all other actual nonscalar data types are user-defined. Users can also define their own incomplete nonscalar data types that are tuple or relation types.

As exceptions to the above 2 paragraphs, the Nothing type and the 2 D0 types are actually complete types, despite being listed here.

sys.std.Core.Type.Tuple

The Tuple type is the maximal type of all Muldis D tuple (nonscalar) types, and contains every tuple value that could possibly exist. A Tuple is an unordered heterogeneous collection of 0..N named attributes (the count of attributes being its degree), where all attribute names are mutually distinct, and each attribute may be of distinct types; the mapping of a tuple's attribute names and their declared data types is called the tuple's heading. Its default value is the sole value of the sole tuple data type that has zero attributes. The cardinality of a complete Tuple type (if it has no type constraints other than those of its constituent attribute types) is equal to the product of the N-ary multiplication where there is an input to that multiplication for each attribute of the tuple and the value of the input is the cardinality of the declared type of the attribute; for a Tuple subtype to be finite, all of its attribute types must be.

sys.std.Core.Type.TupleD0

A TupleD0 is a proper subtype of Tuple that has zero attributes; its cardinality is 1, and its only value is also the default value of Tuple.

sys.std.Core.Type.Database

A Database is a proper subtype of Tuple where all of its attributes are each of relation types or of database types (the leaves of this recursion are all relation types); it is otherwise the same. The 4 system-defined user-data variables named (fed|dep|sdp|pkg).data are all of "just" the Database type, or are of its proper subtypes. It is also trivially a proper supertype of TupleD0.

sys.std.Core.Type.Relation

The Relation type is the maximal type of all Muldis D relation (nonscalar) types, and contains every relation value that could possibly exist. A Relation is analogous to a set of 0..N tuples where all tuples have the same heading (the degrees match and all attribute names and corresponding declared data types match), but that a Relation data type still has its own corresponding heading (attribute names and declared data types) even when it consists of zero tuples. Its default value is the zero-tuple value of the sole relation data type that has zero attributes. The cardinality of a complete Relation type (if it has no type constraints other than those of its constituent attribute types) is equal to 2 raised to the power of the cardinality of the complete Tuple type with the same heading. A relation data type can also have (unique) keys each defined over a subset of its attributes, which constrain its set of values relative to there being no explicit keys, but having the keys won't turn an infinite relation type into a finite one.

sys.std.Core.Type.RelationD0

A RelationD0 is a proper subtype of Relation that has 0 attributes; its cardinality is 2, and its default value is the same as that of Relation.

sys.std.Core.Type.Set

A Set is a proper subtype of Relation that has 1 attribute, and its name is value; it can be of any declared type. A Set subtype is normally used by any system-defined N-ary operators where the order of their argument elements or result is not significant, and that duplicate values are not significant. Its default value has zero tuples. Note that, for any given complete Set subtype, Foo, where its value attribute has a declared type of Bar, the type Foo can be considered the power set of the type Bar.

sys.std.Core.Type.Maybe

A Maybe is a proper subtype of Set that may have at most one element; that is, it is a unary Relation with a nullary key. Operators that work specifically with Maybe subtypes can provide a syntactic shorthand for working with sparse data; so Muldis D has something which is conceptually close to SQL's nullable types without actually having 3-valued logic; it would probably be convenient for code that round-trips SQL by way of Muldis D to use the Maybe type. Its default value has zero tuples.

sys.std.Core.Type.Nothing

A Nothing is a proper subtype of Maybe that has exactly zero elements; its cardinality is 1 and its only value is its default. The single Nothing value, which is a relation with zero tuples and a single attribute named value, is Muldis D's answer to the SQL NULL and is intended to be used for the same purposes; that is, a special marker for missing or inapplicable information, that does not typically equal any normal/scalar value; however, in Muldis D, Nothing is a value, and it is equal to itself.

sys.std.Core.Type.Single

A Single is a proper subtype of Maybe that has exactly 1 element. Its default value's only tuple's only attribute has the value Bool:false. The Single type is complementary to the Nothing type under Maybe; Nothing consists of exactly 1 of Maybe's values, and Single consists of all of Maybe's other values. Subtypes of Single are also used to implement data-carrying database objects that are conceptually scalars rather than relations; for example, the current state of a sequence generator might typically be one.

sys.std.Core.Type.Seq

A Seq is a proper subtype of Relation that has 2 attributes, and their names are index and value, where index is a unary key and its declared type is a UInt subtype (value can be non-unique and of any declared type). A Seq is considered dense, and all index values in one are numbered consecutively from 0 to 1 less than the count of tuples, like array indices in typical programming languages. A Seq subtype is normally used by any system-defined N-ary operators where the order of their argument elements or result is significant (and duplicate values are significant); specifically, index defines an explicit ordering for value. Its default value has zero tuples.

sys.std.Core.Type.Bag

A Bag (or multiset) is a proper subtype of Relation that has 2 attributes, and their names are value and count, where value is a unary key (that can have any declared type) and count is a PInt subtype. A Bag subtype is normally used by any system-defined N-ary operators where the order of their argument elements or result is not significant, but that duplicate values are significant; specifically, count defines an explicit count of occurrences for value, also known as that value's multiplicity. Its default value has zero tuples.

SYSTEM-DEFINED CORE QUASI-SCALAR DATA TYPES ^

There are no system-defined normal quasi-scalar types; the only reason the following exist is to provide a maximal type of any user-defined ones that may come to exist.

sys.std.Core.Type.QuasiScalar

The QuasiScalar type is the maximal type of all Muldis D quasi-scalar types, and contains every quasi-scalar value that can possibly exist. Its default value is QuasiScalarDVPT:default. The cardinality of this type is infinity.

sys.std.Core.Type.QuasiScalarDVPT

A QuasiScalarDVPT is an enumeration consisting of the 1 value QuasiScalarDVPT:default, which is also its default value. The only reason it exists is to provide a default value for the QuasiScalar union type. The cardinality of this type is 1.

SYSTEM-DEFINED CORE QUASI-NONSCALAR PARAMETERIZED DATA TYPES ^

These quasi-nonscalar incomplete data type definitions correspond to their similarly-named (differing only by the Quasi) nonscalar data types, and their use is intended to be limited to the few situations where the corresponding nonscalar data types can't be used. It should be noted in particular that there is no "QuasiDatabase" type, since all normal data or catalog databases should be composed of normal relations only; but all of the other nonscalar incomplete types have counterparts here.

sys.std.Core.Type.QuasiTuple

A QuasiTuple is like a Tuple but that the declared types of its attributes can be anything at all. Its cardinality is infinite.

sys.std.Core.Type.QuasiTupleD0

A QuasiTupleD0 is a proper subtype of QuasiTuple in the corresponding manner to TupleD0 being a proper subtype of Tuple. Its cardinality is 1.

sys.std.Core.Type.QuasiRelation

A QuasiRelation is like a Relation but that the declared types of its attributes can be anything at all. Its cardinality is infinite.

sys.std.Core.Type.QuasiRelationD0

A QuasiRelationD0 is a proper subtype of QuasiRelation in the corresponding manner to RelationD0 being a proper subtype of Relation. Its cardinality is 2.

sys.std.Core.Type.QuasiSet

A QuasiSet is a proper subtype of QuasiRelation in the corresponding manner to Set being a proper subtype of Relation. Its cardinality is infinite.

sys.std.Core.Type.QuasiMaybe

A QuasiMaybe is a proper subtype of QuasiSet in the corresponding manner to Maybe being a proper subtype of Set. Its cardinality is infinite.

sys.std.Core.Type.QuasiNothing

A QuasiNothing is a proper subtype of QuasiMaybe in the corresponding manner to Nothing being a proper subtype of Maybe. Its cardinality is 1.

sys.std.Core.Type.QuasiSingle

A QuasiSingle is a proper subtype of QuasiMaybe in the corresponding manner to Single being a proper subtype of Maybe. Its cardinality is infinite.

sys.std.Core.Type.QuasiSeq

A QuasiSeq is a proper subtype of QuasiRelation in the corresponding manner to Seq being a proper subtype of Relation. Its cardinality is infinite.

sys.std.Core.Type.QuasiBag

A QuasiBag is a proper subtype of QuasiRelation in the corresponding manner to Bag being a proper subtype of Relation. Its cardinality is infinite.

SYSTEM-DEFINED REMNANT TYPES ^

These core data types are mainly for use with the definitions of some polymorphic operators whose range of possibly acceptable values may be mutually incompatible, and they aren't appropriate to group into other type categories or namespaces.

sys.std.Core.Type.Remnant

The Remnant type is a partially redundant maximal type of all Muldis D remnant types. Its default value is Bool:false by way of its ScaTupRel subtype. The cardinality of this type is infinity.

sys.std.Core.Type.ScaTupRel

The ScaTupRel type is a union type over Scalar, Tuple and Relation; it is mainly useful in describing the possible range of types of attributes of scalar possreps or tuples or relations. Its default value is Bool:false.

SEE ALSO ^

Go to Muldis::D for the majority of distribution-internal references, and Muldis::D::SeeAlso for the majority of distribution-external references.

AUTHOR ^

Darren Duncan (perl@DarrenDuncan.net)

LICENSE AND COPYRIGHT ^

This file is part of the formal specification of the Muldis D language.

Muldis D is Copyright © 2002-2008, Darren Duncan.

See the LICENSE AND COPYRIGHT of Muldis::D for details.

TRADEMARK POLICY ^

The TRADEMARK POLICY in Muldis::D applies to this file too.

ACKNOWLEDGEMENTS ^

The ACKNOWLEDGEMENTS in Muldis::D apply to this file too.