NAME
Muldis::D::Core::Universal - Muldis D generic operators for all data types
VERSION
This document is Muldis::D::Core::Universal version 0.107.0.
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 describes essentially all of the core Muldis D generic universal operators, applicable to all data types.
GENERIC FUNCTIONS FOR ALL DATA TYPES
These functions are applicable to values of any data type at all.
sys.std.Core.Universal.is_identical
function sys.std.Core.Universal.is_identical (Bool <-- $topic : Universal, $other : Universal)
This symmetric function results in Bool:True
iff its 2 arguments are exactly the same value, and Bool:False
otherwise. This function will warn if, in regards to the declared types of its arguments, none of the following are true: 1. they are both subtypes of a common scalar root type; 2. they are both subtypes of a common complete 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-Relation
) type, and it is a supertype of the other. Note that this operation is also known as is equal or =
.
sys.std.Core.Universal.is_not_identical
function sys.std.Core.Universal.is_not_identical (Bool <-- $topic : Universal, $other : Universal)
This symmetric function is exactly the same as sys.std.Core.Universal.is_identical
except that it results in the opposite boolean value when given the same arguments. Note that this operation is also known as is not equal or ≠
or !=
.
sys.std.Core.Universal.is_value_of_type
function sys.std.Core.Universal.is_value_of_type (Bool <-- $topic : Universal, $type : APTypeNC)
This function results in Bool:True
iff the value of its topic
argument is a member of the data type whose name is given in the type
argument, and Bool:False
otherwise. As trivial cases, this function always results in Bool:True
if the named type is Universal
, and Bool:False
if it is Empty
. This function will fail if the named type doesn't exist in the virtual machine. Note that this operation is also known as isa
.
sys.std.Core.Universal.is_not_value_of_type
function sys.std.Core.Universal.is_not_value_of_type (Bool <-- $topic : Universal, $type : APTypeNC)
This function is exactly the same as sys.std.Core.Universal.is_value_of_type
except that it results in the opposite boolean value when given the same arguments. Note that this operation is also known as !isa
or not-isa
.
sys.std.Core.Universal.treated
function sys.std.Core.Universal.treated (Universal <-- $topic : Universal, $as : APTypeNC)
This function results in the value of its topic
argument, but that the declared type of the result is the not-Empty
data type whose name is given in the as
argument. This function will fail if the named type doesn't exist in the virtual machine, or if topic
isn't a member of the named type. The purpose of treated
is 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; treated
causes 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 an Int
value in a Scalar
-typed variable, using treated
will cause the compiler to let you use that variable as an argument to sys.std.Core.Integer.diff
, which it otherwise wouldn't. Note that this operation is also known as as
.
sys.std.Core.Universal.default
function sys.std.Core.Universal.default (Universal <-- $of : APTypeNC)
This function is the externalization of a not-Empty
data type's type default named-value
function. This function results in the default value of the not-Empty
data type whose name is given in the of
argument, 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. Note that this operation is also known as d
.
sys.std.Core.Universal.assertion
function sys.std.Core.Universal.assertion (Universal <-- $is_true : Bool, $result : Universal)
This function results in the value of its result
argument, when its is_true
argument is Bool:True
. This function will fail if its is_true
argument is Bool:False
. The purpose of assertion
is to perform condition assertions in a pure functional context that may be better done without the overhead of creating a new constrained data type, especially when the assertion is on some fact that is only known after performing calculations from multiple function arguments; this can potentially be done at compile time as per type constraints. Note that this operation is also known as asserting
.
GENERIC ORDERED-SENSITIVE FUNCTIONS FOR ALL DATA TYPES
These are generic operators that are sensitive to an ordering of a type's values, and are used for such things as list sorting or quota queries or determining before/after/min/max/between/etc. They can potentially be used with values of any data type as long as said data type has a (total) order-determination
function defined for it, and all system-defined conceptually-ordered Muldis D scalar root types do.
Each of these functions which has the parameter named func
is a wrapper over the order-determination
function named in its func
argument when the latter function is curried by a calling-function-specific is_reverse_order
argument value. For any scalar root type's type-default order function, the argument for func
is sys.std.Core.Scalar.order
. Each func
parameter is optional and defaults to sys.std.Core.Scalar.order
if no explicit argument is given to it.
sys.std.Core.Universal.is_before
function sys.std.Core.Universal.is_before (Bool <-- $topic : Universal, $other : Universal, $func? : OrdDetCFuncNC)
This function results in Bool:True
iff the wrapped function would result in Order:Increase
when given the same corresponding 2 arguments plus an is_reverse_order
argument of Bool:False
, and Bool:False
otherwise. Note that this operation is also known as less than or <
.
sys.std.Core.Universal.is_after
function sys.std.Core.Universal.is_after (Bool <-- $topic : Universal, $other : Universal, $func? : OrdDetCFuncNC)
This function is an alias for sys.std.Core.Universal.is_before
except that it transposes the topic
and other
arguments. This function results in Bool:True
iff the wrapped function would result in Order:Decrease
when given the same corresponding 2 arguments plus an is_reverse_order
argument of Bool:False
, and Bool:False
otherwise. Note that this operation is also known as greater than or >
.
sys.std.Core.Universal.is_before_or_same
function sys.std.Core.Universal.is_before_or_same (Bool <-- $topic : Universal, $other : Universal, $func? : OrdDetCFuncNC)
This function is exactly the same as sys.std.Core.Universal.is_before
except that it results in Bool:True
if its 2 primary arguments are identical. Note that this operation is also known as less than or equal to or ≤
.
sys.std.Core.Universal.is_after_or_same
function sys.std.Core.Universal.is_after_or_same (Bool <-- $topic : Universal, $other : Universal, $func? : OrdDetCFuncNC)
This function is an alias for sys.std.Core.Universal.is_before_or_same
except that it transposes the topic
and other
arguments. This function is exactly the same as sys.std.Core.Universal.is_after
except that it results in Bool:True
if its 2 primary arguments are identical. Note that this operation is also known as greater than or equal to or ≥
.
sys.std.Core.Universal.min
function sys.std.Core.Universal.min (Universal <-- $topic : Set, $func? : OrdDetCFuncNC)
This function is a reduction operator that recursively takes each pair of its N input element values and picks the minimum of the 2 (which is commutative, associative, and idempotent) until just one is left, which is the function's result. If topic
has zero values, then this function will fail. Note that, conceptually min
does have an identity value which could be this function's result when topic
has zero values, which is the result type's concept of positive infinity; however, in practice there is little benefit to min
supporting this identity value, since the wrapped order-determination
function can't supply the value, and also many types' concept of positive infinity is impossible or impractically large to represent, such as with the infinite Text
type.
sys.std.Core.Universal.max
function sys.std.Core.Universal.max (Universal <-- $topic : Set, $func? : OrdDetCFuncNC)
This function is exactly the same as sys.std.Core.Universal.min
except that it results in the maximum input element value rather than the minimum one. (Note that, conceptually max
has an identity value which is the result type's concept of negative infinity, but it is unsupported here).
sys.std.Core.Universal.minmax
function sys.std.Core.Universal.minmax (Tuple <-- $topic : Set, $func? : OrdDetCFuncNC)
This function results in a binary tuple whose attribute names are min
and max
and whose respective attribute values are what sys.std.Core.Universal.min
and sys.std.Core.Universal.max
would result in when given the same arguments. If topic
has zero values, then this function will fail.
sys.std.Core.Universal.maybe_min
function sys.std.Core.Universal.maybe_min (Maybe <-- $topic : Set, $func? : OrdDetCFuncNC)
This function is exactly the same as sys.std.Core.Universal.min
except that it results in a Maybe
of what is otherwise the result type, and that result has zero elements if the argument has zero elements, rather than the function failing.
sys.std.Core.Universal.maybe_max
function sys.std.Core.Universal.maybe_max (Maybe <-- $topic : Set, $func? : OrdDetCFuncNC)
This function is to sys.std.Core.Universal.max
as sys.std.Core.Universal.maybe_min
is to sys.std.Core.Universal.min
.
sys.std.Core.Universal.maybe_minmax
function sys.std.Core.Universal.maybe_minmax (Relation <-- $topic : Set, $func? : OrdDetCFuncNC)
This function results in a binary relation whose attribute names are min
and max
. If topic
has zero values then the result has a single tuple whose respective attribute values are what sys.std.Core.Universal.min
and sys.std.Core.Universal.max
would result in when given the same arguments; if topic
has zero values, then the result has zero tuples.
GENERIC UPDATERS FOR ALL DATA TYPES
These update operators are applicable to values of any data type at all.
sys.std.Core.Universal.assign
updater sys.std.Core.Universal.assign (&$target : Universal, $v : Universal)
This update operator will update the variable supplied as its target
argument so that it holds the value supplied as its v
argument. This updater will fail if v
isn't of the declared type of the variable behind target
; this function will otherwise warn if the declared type of v
isn't a subtype of the declared type of the variable behind target
.
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 (darren@DarrenDuncan.net
)
LICENSE AND COPYRIGHT
This file is part of the formal specification of the Muldis D language.
Muldis D is Copyright © 2002-2010, Muldis Data Systems, Inc.
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.