NAME
Language::MuldisD::Core - Muldis D core data types and operators
VERSION
This document is Language::MuldisD::Core version 0.4.0.
PREFACE
This document is part of the Muldis D language specification, whose root document is Language::MuldisD; you should read that root document before you read this one, which provides subservient details.
DESCRIPTION
Muldis D has a mandatory core set of system-defined (eternally available) entities, which is referred to as the Muldis D core or the core; they are the minimal entities that all Muldis D implementations need to provide; they are mutually self-describing and are used to bootstrap the language; any entities outside the core, called Muldis D extensions, are non-mandatory and are defined in terms of the core or each other, but the reverse isn't true.
A significant subset of the Muldis D core entities are specific to being or implementing the Muldis D system catalog / meta-model, and aren't used elsewhere by the system; these are documented in the Language::MuldisD::Catalog document; all the other core entities are described in the current Core document. TODO: EDIT THIS PARAGRAPH.
This current Core document features the boolean, order, integer, bit string, and character string types and operators, plus the tuple and relation type constructors (and quasi- variants) and operators, plus the type system minimal and maximal types, and the polymorphic operators that all types, or some types including core types, have defined over them.
Extensions are in these other documents: Language::MuldisD::Ext::Num, Language::MuldisD::Ext::Temporal, Language::MuldisD::Ext::Spatial.
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.type.Universal
sys.type.Empty
sys.type.Scalar
sys.type.Ordinal
# The following are all regular ordinal scalar types.
sys.type.Bool
sys.type.Order
sys.type.Int
sys.type.UInt
sys.type.PInt
sys.type.PInt2_36
sys.type.Blob
sys.type.NEBlob
sys.type.Text
sys.type.NEText
# The following are all nonscalar type factories.
sys.type.Tuple
sys.type.Database
sys.type.Relation
sys.type.Set
sys.type.Maybe
sys.type.Seq
sys.type.Bag
# The following are all quasi-nonscalar type factories.
sys.type.QuasiTuple
sys.type.QuasiRelation
sys.type.QuasiSet
sys.type.QuasiMaybe
sys.type.QuasiSeq
sys.type.QuasiBag
Note that sys.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.type.Universal-
The
Universaltype 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 ofUniversal, andUniversalis implicitly a union type over all other types. Its default value isBool:false. The cardinality of this type is infinity. sys.type.Empty-
The
Emptytype 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 ofEmptyandEmptyis implicitly an intersection type over all other types. It has no default value. The cardinality of this type is zero.
SYSTEM-DEFINED CORE PSEUDO-TYPES
These are pseudo-types (that is, they aren't types at all) which represent generic contexts that could accept a multiplicity of types, but are not the same as contexts named after some actual types. For example, they are used as the declared parameter types of some dyadic polymorphic operators to refer to, per instance, 2 given types that need to be compatible, but the compatibility isn't simply defined by a "are any 2 subtypes of" such as is true with most operators. They are all system-defined and it is impossible for users to define more types of this nature.
sys.type.Some.Universal-
Contexts defined by the
Some.Universalpseudo-type accept values of potentially any type ofUniversal. sys.type.Some.Ordinal-
Contexts defined by the
Some.Ordinalpseudo-type accept values of potentially any type ofOrdinal.
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. Concrete 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 Language::MuldisD::Grammar. Abstract 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 Language::MuldisD::PerlHosted for a Perl-based example.
sys.type.Scalar-
The
Scalartype 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 ofScalar, andScalaris implicitly a union type over all other scalar types. Its default value isBool:false. The cardinality of this type is infinity. sys.type.Ordinal-
The
Ordinaltype is a proper subtype ofScalarthat is a proper supertype of all scalar types that are considered ordinal. Any scalar types which consider themselves ordinal, which happens to include every system-defined core scalar root type, will explicitly declare themselves as subtypes ofOrdinalin their type definitions; the definition ofOrdinaldoes not specify what other types it is a union over. Its default value isBool:false. The cardinality of this type is infinity. sys.type.Bool-
A
Boolis an enumeration consisting of the 2 valuesBool:falseandBool:true. It represents a truth value, and is the result type of anyis_equaloris_not_equalroutine; it is the only essential scalar data type of a D language. Its default and minimum value isBool:false; its maximum value isBool.true. The cardinality of this type is 2. sys.type.Order-
A
Orderis an enumeration consisting of the 3 valuesOrder:increase,Order:same,Order:decrease. It is the result type of anycompareroutine that is used on 2 values of asys.type.Ordinalsubtype. Its default value isOrder:same; its minimum and maximum values are, respectively,Order.increaseandOrder.decrease. The cardinality of this type is 3. sys.type.Int-
An
Intis a single 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 finiteIntsubtype, you must specify the 2 integer end-points of the inclusive range that all its values are in. sys.type.UInt-
A
UInt(unsigned integer) is a proper subtype ofIntwhere all member values are non-negative / greater than or equal to zero. Its minimum value is zero. sys.type.PInt-
A
PInt(positive integer) is a proper subtype ofUIntwhere all member values are positive / greater than or equal to one. Its default and minimum value is 1. sys.type.PInt2_36-
A
PInt2_36is a proper subtype ofPIntwhere all member values are between 2 and 36. (The significance of the number 36 is 10 digits plus 26 letters.) Its default and minimum value is 2; its maximum value is 36. The cardinality of this type is 35. sys.type.Blob-
A
Blobis 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 finiteBlobsubtype, you must specify a maximum length in bits that the subtype's strings are. sys.type.NEBlob-
A
NEBlob(non-empty blob) is a proper subtype ofBlobwhere its length in bits must be at least 1; it can be anyBlobexcept for the empty string. Its default and minimum value is a single zero bit. sys.type.Text-
A
Textis 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 forTexttypes, which is the newest Unicode repertoire (5.0.0). The cardinality of this type is infinity; to define a most-generalized finiteTextsubtype, you must specify a maximum length in characters (that is, eg, in NFC graphemes) that the subtype's strings are. sys.type.NEText-
A
NEText(non-empty text) is a proper subtype ofTextwhere its length in characters must be more than zero; it can be anyTextexcept for the empty string. Its default value is a single "space" character; its minimum value has one character, but which character that is depends on the default or current collation.
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 Language::MuldisD::Catalog for more details), 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.
sys.type.Tuple-
The
Tupletype is the maximal type of all Muldis D tuple (nonscalar) types, and contains every tuple value that could possibly exist. ATupleis 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 this type is equal to the product of the number of permutations drawable from the values of each of its attributes' declared data types; for aTuplesubtype to be finite, all of its attribute types must be. sys.type.Database-
A
Databaseis a proper subtype ofTuplewhere all of its attributes are of relation types; it is otherwise the same. sys.type.Relation-
The
Relationtype is the maximal type of all Muldis D relation (nonscalar) types, and contains every relation value that could possibly exist. ARelationis 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 aRelationdata 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. Matters of its cardinality are generally the same as forTuple. 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.type.Set-
A
Setis a proper subtype ofRelationthat has 1 attribute, and its name isvalue; it can be of any declared type. ASetsubtype 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. sys.type.Maybe-
A
Maybeis a proper subtype ofSetthat may have at most one element; that is, it is a unaryRelationwith a nullary key. Operators that work specifically withMaybesubtypes 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 theMaybetype. Its default value has zero tuples. sys.type.Seq-
An
Seqis a proper subtype ofRelationthat has 2 attributes, and their names areindexandvalue, whereindexis a unary key and its declared type is anUIntsubtype (valuecan be non-unique and of any declared type). A Seq is considered dense, and allindexvalues in one are numbered consecutively from 0 to 1 less than the count of tuples, like array indices in typical programming languages. ASeqsubtype 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,indexdefines an explicit ordering forvalues. Its default value has zero tuples. sys.type.Bag-
A
Bagis a proper subtype ofRelationthat has 2 attributes, and their names arevalueandcount, wherevalueis a unary key (that can have any declared type) andcountis aPIntsubtype. ABagsubtype 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,countdefines an explicit count of occurrences forvalues. Its default value has zero tuples.
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.type.QuasiTuple-
A
QuasiTupleis like aTuplebut that the declared types of its attributes can be anything at all. Its cardinality is infinite. sys.type.QuasiRelation-
A
QuasiRelationis like aRelationbut that the declared types of its attributes can be anything at all. Its cardinality is infinite. sys.type.QuasiSet-
A
QuasiSetis a proper subtype ofQuasiRelationin the corresponding manner toSetbeing a proper subtype ofRelation. Its cardinality is infinite. sys.type.QuasiMaybe-
A
QuasiMaybeis a proper subtype ofQuasiRelationin the corresponding manner toMaybebeing a proper subtype ofRelation. Its cardinality is infinite. sys.type.QuasiSeq-
A
QuasiSeqis a proper subtype ofQuasiRelationin the corresponding manner toSeqbeing a proper subtype ofRelation. Its cardinality is infinite. sys.type.QuasiBag-
A
QuasiBagis a proper subtype ofQuasiRelationin the corresponding manner toBagbeing a proper subtype ofRelation. Its cardinality is infinite.
SYSTEM-DEFINED GENERIC UNIVERSAL FUNCTIONS
These functions are applicable to values of any data type at all.
sys.rtn.Universal.is_equal of Bool (RO: Some.Universal $v1, Some.Universal $v2)-
This function results in
Bool:trueiff its 2 arguments are exactly the same value, andBool:falseotherwise. This function's arguments must be of compatible declared types; in this case, 2 declared types are compatible iff at least one of the following is true: 1. they are both subtypes of a common scalar root type; 2. they are both subtypes of a common non-incomplete tuple or relation type, that is they essentially have the same headings; 3. at least one type is a generic (eg-Universal) or incomplete (eg-Seq) type, and it is a supertype of the other. This function is commutative. sys.rtn.Universal.is_not_equal of Bool (RO: Some.Universal $v1, Some.Universal $v2)-
This function is exactly the same as
sys.rtn.Universal.is_equalexcept that it results in the opposite boolean value when given the same arguments. sys.rtn.Universal.is_value_of_type of Bool (RO: Cat.LongName $type, Universal $v)-
This function results in
Bool:trueiff the value of its$vargument is a member of the data type whose name is given in the$typeargument, andBool:falseotherwise. As trivial cases, this function always results inBool:trueif the named type isUniversal, andBool:falseif it isEmpty. This function will fail if the named type doesn't exist in the virtual machine. sys.rtn.Universal.treat of Some.Universal (RO: Cat.LongName $as, Some.Universal $v)-
This function results in the value of its
$vargument, but that the declared type of the result is the not-Emptydata type whose name is given in the$asargument. This function will fail if the named type doesn't exist in the virtual machine, or if$visn't a member of the named type. The purpose oftreatis to permit taking values from a context having a more generic declared type, and using them in a context having a more specific declared type; such an action would otherwise be blocked at compile time due to a type-mismatch error;treatcauses the type-mismatch validation, and possible failure, to happen at runtime instead, on the actual value rather than declared value. For example, if you are storing anIntvalue in aScalar-typed variable, usingtreatwill cause the compiler to let you use that variable as an argument toInt.sum, which it otherwise wouldn't. sys.rtn.Universal.default of Some.Universal (RO: Cat.LongName $of)-
This function results in the default value of the not-
Emptydata type whose name is given in the$ofargument, and the declared type of the result is that same type. This function will fail if the named type doesn't exist in the virtual machine, either at compile or runtime depending whether the type is in the system or user namespace. This function is conceptually implicitly used to provide default values for variables, so they always hold valid values of their declared type.
SYSTEM-DEFINED GENERIC UNIVERSAL UPDATE OPERATORS
These update operators are applicable to values of any data type at all.
sys.rtn.Universal.assign (UPD: Some.Universal $target ; RO: Some.Universal $v)-
This update operator will update the variable supplied as its
$targetargument so that it holds the value supplied as its$vargument. This update operator's arguments must be of compatible declared types; in this case,$vmust be a subtype of$target.
SYSTEM-DEFINED GENERIC ORDINAL FUNCTIONS
These functions are applicable to values of any data type which is a subtype of Ordinal. They provide a common syntax for sort-related functionality, though technically every type having these functions is re-implementing its own version. If values of an ordinal data type can conceivably be sorted using multiple criteria (such as different text collations), then these functions just represent the default criteria; any additional criteria are represented by additional functions declared for just the types they apply to.
sys.rtn.Ordinal.compare of Order (RO: Some.Ordinal $v1, Some.Ordinal $v2)-
This function results in
Order:sameiff its 2 arguments are exactly the same value, and otherwise it results inOrder:increaseif the value of the$v2argument is considered to be an increase (as defined by the type) over the value of the$v1argument, and otherwise it results inOrder:decreaseas the reverse of the last condition would be true. This function's arguments must be of compatible declared types; in this case, 2 declared types are compatible iff they are both subtypes of a common scalar type that declares itself anOrdinalsubtype. Note thatcompareis considered the only fundamental ordinal-specific operator, and all others are defined over it. sys.rtn.Ordinal.reverse_compare of Order (RO: Some.Ordinal $v1, Some.Ordinal $v2)-
This function is exactly the same as
sys.rtn.Ordinal.compareexcept that it results in the reverse value when given the same arguments. It is a short-hand for applyingsys.rtn.Order.reverseto the result ofsys.rtn.Ordinal.comparewith the same arguments. sys.rtn.Ordinal.is_increase of Bool (RO: Some.Ordinal $v1, Some.Ordinal $v2)-
This function results in
Bool:trueiffsys.rtn.Ordinal.comparewould result inOrder:increasewhen given the same arguments, andBool:falseotherwise. sys.rtn.Ordinal.is_decrease of Bool (RO: Some.Ordinal $v1, Some.Ordinal $v2)-
This function results in
Bool:trueiffsys.rtn.Ordinal.comparewould result inOrder:decreasewhen given the same arguments, andBool:falseotherwise. sys.rtn.Ordinal.min of Some.Ordinal (RO: Set{Some.Ordinal} $v)-
This function is a reduction operator that recursively takes each pair of its N input element values and picks the minimum of the 2 (a process which is both commutative and associative) until just one is left, which is the function's result. If
$vhas zero values, thenminresults in the result type's concept of positive infinity, which is the identity value for min. This function will fail on a$vof zero values if the result type's concept of positive infinity is impossible or impractically large to represent, such as with the infiniteTexttype. sys.rtn.Ordinal.max of Some.Ordinal (RO: Set{Some.Ordinal} $v)-
This function is exactly the same as
sys.rtn.Ordinal.minexcept that it results in the maximum input element value rather than the minimum one, and its identity value is the result type's concept of negative infinity. sys.rtn.Ordinal.maybe_min of Maybe{Some.Ordinal} (RO: Set{Some.Ordinal} $v)-
This function is exactly the same as
sys.rtn.Ordinal.minexcept that it results in aMaybeof what is otherwise the result type, and that result has zero elements if the argument has zero elements. sys.rtn.Ordinal.maybe_max of Maybe{Some.Ordinal} (RO: Set{Some.Ordinal} $v)-
This function is to
sys.rtn.Ordinal.maxassys.rtn.Ordinal.maybe_minis tosys.rtn.Ordinal.min.
SYSTEM-DEFINED CORE SCALAR FUNCTIONS
These functions are applicable to just one or more specific system-defined core scalar data type.
Functions for sys.type.Bool
These functions select values of the Bool enumeration.
sys.rtn.Bool.false of Bool ()-
This selector function results in the
Bool:falsevalue. sys.rtn.Bool.true of Bool ()-
This selector function results in the
Bool:truevalue.
These functions implement commonly used boolean operations.
sys.rtn.Bool.not of Bool (RO: Bool $v)-
This function results in the logical not of its argument.
sys.rtn.Bool.and of Bool (RO: Set{Bool} $v)-
This function is a reduction operator that recursively takes each pair of its N input element values and does a logical and (which is both commutative and associative) on them until just one is left, which is the function's result. If
$vhas zero values, thenandresults inBool:true, which is the identity value for logical and. sys.rtn.Bool.or of Bool (RO: Set{Bool} $v)-
This function is a reduction operator that recursively takes each pair of its N input element values and does a logical inclusive-or (which is both commutative and associative) on them until just one is left, which is the function's result. If
$vhas zero values, thenorresults inBool:false, which is the identity value for logical inclusive-or. sys.rtn.Bool.xor of Bool (RO: Bag{Bool} $v)-
This function is a reduction operator that recursively takes each pair of its N input element values and does a logical exclusive-or (which is both commutative and associative) on them until just one is left, which is the function's result. If
$vhas zero values, thenxorresults inBool:false, which is the identity value for logical exclusive-or.
Functions for sys.type.Order
These functions select values of the Order enumeration.
sys.rtn.Order.increase of Order ()-
This selector function results in the
Order:increasevalue. sys.rtn.Order.same of Order ()-
This selector function results in the
Order:samevalue. sys.rtn.Order.decrease of Order ()-
This selector function results in the
Order:decreasevalue.
These functions implement commonly used order-enumeration operations.
sys.rtn.Order.reverse of Order (RO: Order $v)-
This function results in the reverse value of its argument; an
Order:increaseorOrder:decreaseargument results in the other one of the two; anOrder:sameargument results inOrder:same.
Functions for sys.type.Int
These functions implement commonly used integer operations.
sys.rtn.Int.sum of Int (RO: Bag{Int} $addends)-
This function results in the sum of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and adds (which is both commutative and associative) them together until just one is left, which is the result. If
$addendshas zero values, thensumresults in the integer zero, which is the identity value for addition. sys.rtn.Int.difference of Int (RO: Int $minuend, Int $subtrahend)-
This function results in the difference when its
$subtrahendargument is subtracted from its$minuendargument. sys.rtn.Int.product of Int (RO: Bag{Int} $factors)-
This function results in the product of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and multiplies (which is both commutative and associative) them together until just one is left, which is the result. If
$factorshas zero values, thenproductresults in the integer 1, which is the identity value for multiplication. sys.rtn.Int.quotient of Int (RO: Int $dividend, Int $divisor)-
This function results in the quotient when its
$dividendargument is divided by its$divisorargument using integer division. This function will fail if$divisoris zero. sys.rtn.Int.remainder of UInt (RO: Int $dividend, Int $divisor)-
This function results in the remainder when its
$dividendargument is divided by its$divisorargument using integer division. This function will fail if$divisoris zero. sys.rtn.Int.abs of UInt (RO: Int $v)-
This function results in the absolute value of its argument.
sys.rtn.Int.power of Int (RO: Int $radix, PInt $exponent)-
This function results in its
$radixargument taken to the power of its (positive integer)$exponentargument.
These functions convert between Int values and canonically formatted representations of integers as character strings.
sys.rtn.Int.Int_from_Text of Int (RO: NEText $text, PInt2_36 $radix)-
This selector function results in the
Intvalue that its$textargument maps to when the whole character string is evaluated as a base-$radixinteger. Extending the typical formats of [base-2, base-8, base-10, base-16], this function supports base-2 through base-36; to get the latter, the characters 0-9 and A-Z represent values in 0-35. This function will fail if$textcan't be mapped as specified. sys.rtn.Int.Text_from_Int of NEText (RO: Int $int, PInt2_36 $radix)-
This selector function results in the
Textvalue where its$intargument is formatted as a base-$radixinteger.
These functions convert between Int values and canonically formatted representations of integers as binary strings. Conjecture: These may not actually be useful, and perhaps only operators that take an argument specifying a fixed-length field size, with big and little endian versions, would be appropriate instead. Or maybe both kinds are necessary.
sys.rtn.Int.Int_from_Blob_S_VBE of Int (RO: NEBlob $blob)-
This selector function results in the
Intvalue that its$blobargument maps to when the whole bit string is treated literally as a variable-length binary (two's complement) signed integer of 1 or more bits in length. The first bit is taken as the sign bit, and any other bits provide greater precision than the -1 thru 0 range. The bit string is assumed to be big-endian, since it may not be possible to use little-endian in situations where the bit length isn't a multiple of 8. sys.rtn.Int.Blob_S_VBE_from_Int of NEBlob (RO: Int $int)-
This selector function results in the
Blobvalue where its$intargument is formatted as a variable-length binary (two's complement) signed integer of 1 or more bits in length; the smallest number of bits necessary to store$intis used. sys.rtn.Int.Int_from_Blob_U_VBE of UInt (RO: NEBlob $blob)-
This function is the same as
sys.rtn.Int.Int_from_Blob_S_VBEbut that it does unsigned integers. sys.rtn.Int.Blob_U_VBE_from_Int of UInt (RO: NEBlob $blob)-
This function is the same as
sys.rtn.Int.Blob_S_VBE_from_Intbut that it does unsigned integers.
Functions for sys.type.Blob
These functions implement commonly used binary string operations.
sys.rtn.Blob.catenate of Blob (RO: Seq{Blob} $v)-
This function results in the catenation of the N element values of its argument; it is a reduction operator that recursively takes each consecutive pair of input values and catenates (which is associative) them together until just one is left, which is the result. If
$vhas zero values, thencatenateresults in the empty string value, which is the identity value for catenate. sys.rtn.Blob.repeat of Blob (RO: Blob $v, UInt $count)-
This function results in the catenation of
$countinstances of$v. sys.rtn.Blob.length_in_bits of UInt (RO: Blob $v)-
This function results in the length of its argument in bits.
sys.rtn.Blob.contains of Bool (RO: Blob $look_in, Blob $look_for, Bool $fixed_start, Bool $fixed_end)-
This function results in
Bool:trueiff its$look_forargument is a substring of its$look_inargument as per the optional$fixed_startand$fixed_endconstraints, andBool:falseotherwise. If$fixed_startor$fixed_endareBool:true, then$look_formust occur right at the start or end, respectively, of$look_inin order forcontainsto results inBool:true; if either flag isBool:false, its additional constraint doesn't apply. sys.rtn.Blob.not of Blob (RO: Blob $v)-
This function results in the bitwise not of its argument.
sys.rtn.Blob.and of Blob (RO: Set{Blob} $v)-
This function is a reduction operator that recursively takes each pair of its N input element values and does a bitwise and (which is both commutative and associative) on them until just one is left, which is the function's result. This function's argument values must all be of the same length in bits, that length being part of the argument's declared type (that is,
Blobsubtype) definition, and that is also the length in bits of the function's result. If$vhas zero values, thenandwill result in an appropriate-length string of identity/1 valued bits. sys.rtn.Blob.or of Blob (RO: Set{Blob} $v)-
This function is the same as
sys.rtn.Blob.andbut that it recursively does a bitwise inclusive-or rather than a bitwise and, and its identity value is composed of zero valued bits. sys.rtn.Blob.xor of Blob (RO: Bag{Blob} $v)-
This function is the same as
sys.rtn.Blob.orbut that it recursively does a bitwise exclusive-or rather than a bitwise inclusive-or.
These functions convert between Blob values and canonically formatted representations of binary strings as character strings.
sys.rtn.Blob.Blob_from_Text_2 of Blob (RO: Text $text)-
This selector function results in the
Blobvalue that its argument maps to when each input character is a [0-1] and represents a bit. sys.rtn.Blob.Text_from_Blob_2 of Text (RO: Blob $blob)-
This selector function results in the
Textvalue where its argument is encoded using a [0-1] character for each bit. sys.rtn.Blob.Blob_from_Text_16 of Blob (RO: Text $text)-
This selector function results in the
Blobvalue that its argument maps to when each input character is a [0-9A-F] and represents a hex digit. sys.rtn.Blob.Text_from_Blob_16 of Text (RO: Blob $blob)-
This selector function results in the
Textvalue where its argument is encoded using a [0-9A-F] character for each bit.
Functions for sys.type.Text
These functions implement commonly used character string operations.
sys.rtn.Text.catenate of Text (RO: Seq{Text} $v)-
This function results in the catenation of the N element values of its argument; it is a reduction operator that recursively takes each consecutive pair of input values and catenates (which is associative) them together until just one is left, which is the result. If
$vhas zero values, thencatenateresults in the empty string value, which is the identity value for catenate. sys.rtn.Text.repeat of Text (RO: Text $v, UInt $count)-
This function results in the catenation of
$countinstances of$v. sys.rtn.Text.length_in_nfd_graphs of UInt (RO: Text $v)-
This function results in the length of its argument in Unicode Normalization Form D graphemes.
sys.rtn.Text.length_in_nfc_graphs of UInt (RO: Text $v)-
This function results in the length of its argument in Unicode Normalization Form C graphemes.
sys.rtn.Text.length_in_nfd_codes of UInt (RO: Text $v)-
This function results in the length of its argument in Unicode Normalization Form D code points.
sys.rtn.Text.length_in_nfc_codes of UInt (RO: Text $v)-
This function results in the length of its argument in Unicode Normalization Form C code points.
sys.rtn.Text.contains of Bool (RO: Text $look_in, Text $look_for, Bool $fixed_start, Bool $fixed_end)-
This function results in
Bool:trueiff its$look_forargument is a substring of its$look_inargument as per the optional$fixed_startand$fixed_endconstraints, andBool:falseotherwise. If$fixed_startor$fixed_endareBool:true, then$look_formust occur right at the start or end, respectively, of$look_inin order forcontainsto result inBool:true; if either flag isBool:false, its additional constraint doesn't apply. sys.rtn.Text.fold_case_to_upper (RO: Text $v)-
This function results in the transformation of its argument where any Latin letters are folded to (capital) uppercase.
sys.rtn.Text.fold_case_to_lower (RO: Text $v)-
This function results in the transformation of its argument where any Latin letters are folded to (small) lowercase.
sys.rtn.Text.trim_whitespace (RO: Text $v)-
This function results in the value of its argument but that any leading or trailing whitespace characters are trimmed.
SYSTEM-DEFINED CORE SCALAR UPDATE OPERATORS
These update operators are applicable to just one or more specific system-defined core scalar data type.
This documentation is pending.
SYSTEM-DEFINED CORE SCALAR SYSTEM SERVICES
These system services are applicable to just one or more specific system-defined core scalar data type.
This documentation is pending.
SYSTEM-DEFINED CORE GENERIC NONSCALAR FUNCTIONS
These functions are applicable to mainly nonscalar types, but are generic in that they typically work with any nonscalar types.
Functions for sys.type.Tuple
These functions implement commonly used relational operations that take a single tuple as input.
sys.rtn.Tuple.degree of UInt (RO: Tuple $v)-
This function results in the degree of its argument (that is, the count of attributes it has).
sys.rtn.Tuple.rename of Tuple (RO: Tuple $v, Cat.AttrRenameMap $map)-
This function results in a
Tuplevalue that is the same as its$vargument but that some of its attributes have different names. Each tuple of the argument$mapspecifies how to rename one$vattribute, with thebeforeandafterattributes of a$maptuple representing the old and new names of a$vattribute, respectively. As a trivial case, this function's result is$vif$maphas no tuples. This function supports renaming attributes to each others' names. This function will fail if$mapspecifies any old names that$vdoesn't have, or any new names that are the same as$vattributes that aren't being renamed. sys.rtn.Tuple.project of Tuple (RO: Tuple $v, Cat.ShortNameSet $attrs)-
This function results in the projection of its
$vargument that has just the subset of attributes of$vwhich are named in its$attrsargument. As a trivial case, this function's result is$vif$attrslists all attributes of$v; or, it is the nullary tuple if$attrsis empty. This function will fail if$attrsspecifies any attribute names that$vdoesn't have. sys.rtn.Tuple.remove of Tuple (RO: Tuple $v, Cat.ShortNameSet $attrs)-
This function is the same as
projectbut that it results in the complementary subset of attributes of$vwhen given the same arguments. sys.rtn.Tuple.wrap of Tuple (RO: Tuple $v, Cat.ShortNameSet $inner, Cat.ShortName $outer)-
This function results in a
Tuplevalue that is the same as its$vargument but that some of its attributes have been wrapped up into a newTuple-typed attribute, which exists in place of the original attributes. The$innerargument specifies which$vattributes are to be removed and wrapped up, and the$outerargument specifies the name of their replacement attribute. As a trivial case, if$inneris empty, then the result has all the same attributes as before plus a new nullary tuple attribute; or, if$innerlists all attributes of$v, then the result has a single attribute whose value is the same as$v. This function supports the new attribute having the same name as an old one being wrapped into it. This function will fail if$innerspecifies any attribute names that$vdoesn't have, or if$outeris the same as$vattributes that aren't being wrapped. sys.rtn.Tuple.unwrap of Tuple (RO: Tuple $v, Cat.ShortName $outer)-
This function is the inverse of
sys.rtn.Tuple.wrap, such that it will unwrap aTuple-type attribute into its member attributes. This function will fail if$outerspecifies any attribute name that$vdoesn't have, or if an attribute of$v{$outer}is the same as a$vattribute. sys.rtn.Tuple.extend-
TODO.
Functions for sys.type.Relation
These functions implement commonly used relational operations that take a single relation as input.
sys.rtn.Relation.degree of UInt (RO: Relation $v)-
This function results in the degree of its argument (that is, the count of attributes it has).
sys.rtn.Relation.cardinality of UInt (RO: Relation $v)-
This function results in the cardinality of its argument (that is, the count of tuples its body has).
sys.rtn.Relation.is_empty of Bool (RO: Relation $v)-
This function results in
Bool:trueiff its argument has zero tuples, andBool:falseotherwise. Note that if you are using aMaybeto represent a sparse data item, analagously to a SQL nullable context, then testing theMaybewithis_emptyis analagous to testing a SQL nullable withis null. sys.rtn.Relation.is_not_empty of Bool (RO: Relation $v)-
This function is exactly the same as
sys.rtn.Relation.emptyexcept that it results in the opposite boolean value when given the same argument. And following the analogy withis_empty,is_not_emptyis analagous to SQL'sis not null. sys.rtn.Relation.exists of Bool (RO: Relation $r, Tuple $t)-
This function results in
Bool:trueiff its$targument matches a tuple of its$rargument, andBool:falseotherwise. This function is likesys.rtn.Relation.containsexcept that the tuple being looked for doesn't have to be wrapped in a relation. This function will fail if the 2 arguments don't have the same heading. sys.rtn.Relation.Tuple_from_Relation of Tuple (RO: Relation $v)-
This function results in the
Tuplethat is the sole member tuple of its argument. This function will fail if its argument does not have exactly one tuple. sys.rtn.Relation.Relation_from_Tuple of Relation (RO: Tuple $v)-
This function results in the
Relationvalue those body has just the oneTuplethat is its argument. sys.rtn.Relation.insert of Relation (RO: Relation $r, Tuple $t)-
This function results in a
Relationthat is the relational union of$rand a relation whose sole tuple is$t; that is, conceptually the result is$tinserted into$r. As a trivial case, if$talready exists in$r, then the result is just$r. sys.rtn.Relation.delete of Relation (RO: Relation $r, Tuple $t)-
This function results in a
Relationthat is the relational difference of a relation whose sole tuple is$tand$r; that is, conceptually the result is$tdeleted from$r. As a trivial case, if$talready doesn't exist in$r, then the result is just$r. sys.rtn.Relation.evacuate of Relation (RO: Relation $v)-
This function results in a
Relationthat has the same heading as its argument, but with an empty body. sys.rtn.Relation.not of Relation (RO: Relation $v)-
This function results in the relational not of its argument. The result relation has the same heading as its argument, and its body contains all of the tuples that are in the universal relation of the same heading (that is, the relation having all the tuples that could ever exist in a relation with that heading) and that are not in the argument; that is, the result is the relational difference when the argument is subtracted from said universal relation. This function will fail if said universal relation is impossible or impractically large to represent, such as when any attributes are of infinite types.
sys.rtn.Relation.rename of Relation (RO: Relation $v, Cat.AttrRenameMap $map)-
This function is the same as
sys.rtn.Tuple.renamebut that it operates on and results in aRelationrather than aTuple. sys.rtn.Relation.project of Relation (RO: Relation $v, Cat.ShortNameSet $attrs)-
This function is the same as
sys.rtn.Tuple.projectbut that it operates on and results in aRelationrather than aTuple. But note that the result relation will have fewer tuples than$vif any$vtuples were non-distinct for just the projected attributes. sys.rtn.Relation.remove of Relation (RO: Relation $v, Cat.ShortNameSet $attrs)-
This function is the same as
sys.rtn.Tuple.removebut that it operates on and results in aRelationrather than aTuple. sys.rtn.Relation.wrap of Relation (RO: Relation $v, Cat.ShortNameSet $inner, Cat.ShortName $outer)-
This function is the same as
sys.rtn.Tuple.wrapbut that it operates on and results in aRelationrather than aTuple, where each of its member tuples was transformed as persys.rtn.Tuple.wrap. sys.rtn.Relation.unwrap of Relation (RO: Relation $v, Cat.ShortName $outer)-
This function is the inverse of
sys.rtn.Relation.wrapassys.rtn.Tuple.unwrapis tosys.rtn.Tuple.wrap. sys.rtn.Relation.group of Relation (RO: Relation $v, Cat.ShortNameSet $inner, Cat.ShortName $outer)-
TODO.
sys.rtn.Relation.ungroup of Relation (RO: Relation $v, Cat.ShortName $outer)-
TODO.
sys.rtn.Relation.tclose of Relation (RO: Relation $v)-
This function results in the transitive closure of its argument. The argument is a binary relation whose attributes are both of the same declared type, and the result is a relation having the same heading and a body which is a superset of the argument's tuples. Assuming that the argument represents all of the node pairs in a directed graph that have an arc between them, and so each argument tuple represents an arc,
tclosewill determine all of the node pairs in that graph which have a path between them (a recursive operation), so each tuple of the result represents a path. The result is a superset since all arcs are also complete paths. Thetclosefunction is intended to support recursive queries, such as in connection with the "part explosion problem" (the problem of finding all components, at all levels, of some specified part). sys.rtn.Relation.restrict-
TODO.
sys.rtn.Relation.extend-
TODO.
sys.rtn.Relation.summarize-
TODO.
sys.rtn.Relation.substitute-
TODO.
These functions implement commonly used relational operations that take a multiple relations as input.
sys.rtn.Relation.contains of Bool (RO: Relation $look_in, Relation $look_for)-
This function results in
Bool:trueiff the set of tuples comprising$look_foris a subset of the set of tuples comprising$look_in, andBool:falseotherwise. This function will fail if the 2 arguments don't have the same heading. sys.rtn.Relation.union of Relation (RO: Set{Relation} $v)-
This function results in the relational union/inclusive-or of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and relationally unions (which is both commutative and associative) them together until just one is left, which is the result. The result relation has the same heading as all of its inputs, and its body contains every tuple that is in any of the input relations. If
$vhas zero values, thenunionresults in the empty relation with the same heading, which is the per-distinct-heading identity value for relational union. sys.rtn.Relation.exclusion of Relation (RO: Bag{Relation} $v)-
This function results in the relational exclusion/exclusive-or of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and relationally excludes (which is both commutative and associative) them together until just one is left, which is the result. The result relation has the same heading as all of its inputs, and its body contains every tuple that is in just an odd number of the input relations. If
$vhas zero values, thenexclusionresults in the empty relation with the same heading, which is the per-distinct-heading identity value for relational exclusion. Note that this operation is also legitimately known as symmetric difference, or disjoint union. sys.rtn.Relation.intersection of Relation (RO: Set{Relation} $v)-
This function results in the relational intersection/and of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and relationally intersects (which is both commutative and associative) them together until just one is left, which is the result. The result relation has the same heading as all of its inputs, and its body contains only the tuples that are in every one of the input relations. If
$vhas zero values, thenintersectionresults in the universal relation with the same heading (that is, the relation having all the tuples that could ever exist in a relation with that heading), which is the per-distinct-heading identity value for relational intersection. Note that this intersection operator is conceptually a special case ofjoin, applicable when the headings of the inputs are the same, and the other will produce the same result as this when given the same inputs, but with the exception that intersection has a different identity value when given zero inputs. This function will fail on a$vof zero values if the result type's universal relation is impossible or impractically large to represent, such as when any attributes are of infinite types. sys.rtn.Relation.difference of Relation (RO: Relation $source, Relation $filter)-
This function results in the relational difference when its
$filterargument is subtracted from its$sourceargument. The result relation has the same heading as both of its arguments, and its body contains only the tuples that are in$sourceand are not in$filter. This function will fail if its 2 arguments do not have the same heading. Note that this difference operator is conceptually a special case of semidifference, applicable when the headings of the inputs are the same. sys.rtn.Relation.semidifference of Relation (RO: Relation $source, Relation $filter)-
This function is the same as
semijoinbut that it results in the complementary subset of tuples of$sourcewhen given the same arguments. sys.rtn.Relation.semijoin of Relation (RO: Relation $source, Relation $filter)-
This function results in the relational semijoin of its
$sourceand$filterarguments. The result relation has the same heading as$source, and its body contains the subset of$sourcetuples that match those of$filteras perjoin. Note that relational semijoin is conceptually a short-hand for first doing an ordinary relational join between its 2 arguments, and then performing a relational projection on all of the attributes that just$sourcehas. This function will fail any time thatjoinwould fail on the same 2 input relations. sys.rtn.Relation.join of Relation (RO: QuasiSet{Relation} $v)-
This function results in the relational join of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and relationally joins (which is both commutative and associative) them together until just one is left, which is the result. The result relation has a heading that is a union of all of the headings of its inputs, and its body is the result of first pairwise-matching every tuple of each input relation with every tuple of each other input relation, then where each member of a tuple pair has attribute names in common, eliminating pairs where the values of those attributes differ and unioning the remaining said tuple pairs, then eliminating any result tuples that duplicate others. If
$vhas zero values, thenjoinresults in the nullary relation with one tuple, which is the identity value for relational join. As a trivial case, if any input relation has zero tuples, then the function's result will too; or, if any input is the nullary relation with one tuple, that input can be ignored (see identity value); or, if any 2 inputs have no attribute names in common, then the join of just those 2 is a cartesian product; or, if any 2 inputs have all attribute names in common, then the join of just those 2 is an intersection; or, if for 2 inputs, one's set of attribute names is a proper subset of another's, then the join of just those to is a semijoin with the former filtering the latter. This function will fail if any input relations have attributes with common names but different/incompatible declared types. Note that this operation is also legitimately known as natural inner join. sys.rtn.Relation.compose of Relation (RO: Relation $v1, Relation $v2)-
This function results in the relational composition of its 2 arguments. It is conceptually a short-hand for first doing an ordinary relational join between its 2 arguments, and then performing a relational projection on all of the attributes that only one of the arguments has; that is, the result has all of and just the attributes that were not involved in matching the tuples of the 2 arguments. This function will fail any time that
joinwould fail on the same 2 input relations. sys.rtn.Relation.divide-
TODO.
SYSTEM-DEFINED CORE GENERIC NONSCALAR UPDATE OPERATORS
These update operators are applicable to mainly nonscalar types, but are generic in that they typically work with any nonscalar types.
SYSTEM-DEFINED CORE GENERIC QUASI-NONSCALAR FUNCTIONS
This documentation is pending.
SYSTEM-DEFINED CORE GENERIC QUASI-NONSCALAR UPDATE OPERATORS
This documentation is pending.
SEE ALSO
Go to Language::MuldisD for the majority of distribution-internal references, and Language::MuldisD::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-2007, Darren Duncan.
See the LICENSE AND COPYRIGHT of Language::MuldisD for details.
ACKNOWLEDGEMENTS
The ACKNOWLEDGEMENTS in Language::MuldisD apply to this file too.