NAME
Language::MuldisD::Core::Routines - Muldis D general purpose routines
VERSION
This document is Language::MuldisD::Core::Routines version 0.19.1.
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. Moreover, you should read the Language::MuldisD::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 Language::MuldisD::Core so that that other document would not be too large.
SYSTEM-DEFINED GENERIC UNIVERSAL FUNCTIONS
These functions are applicable to values of any data type at all.
function sys.Core.Universal.is_identical result Bool params { topic(Universal), other(Universal) }-
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's 2 parameters are mutually commutative. function sys.Core.Universal.is_not_identical result Bool params { topic(Universal), other(Universal) }-
This function is exactly the same as
sys.Core.Universal.is_identicalexcept that it results in the opposite boolean value when given the same arguments. function sys.Core.Universal.is_value_of_type result Bool params { topic(Universal), type(Cat.NameChain) }-
This function results in
Bool:trueiff the value of itstopicargument is a member of the data type whose name is given in thetypeargument, 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. function sys.Core.Universal.treated result Universal params { topic(Universal), as(Cat.NameChain) }-
This function results in the value of its
topicargument, but that the declared type of the result is the not-Emptydata type whose name is given in theasargument. This function will fail if the named type doesn't exist in the virtual machine, or iftopicisn't a member of the named type. The purpose oftreatedis 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;treatedcauses 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, usingtreatedwill cause the compiler to let you use that variable as an argument toInt.sum, which it otherwise wouldn't. function sys.Core.Universal.default result Universal params { of(Cat.NameChain) }-
This function results in the default value of the not-
Emptydata type whose name is given in theofargument, 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 ORDERED FUNCTIONS
These functions are applicable to values of any data type which is a subtype of Ordered. 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 ordered 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.
function sys.Core.Ordered.is_before result Bool params { topic(Ordered), other(Ordered) }-
This function results in
Bool:trueiff its 2 arguments are non-identical and the value of thetopicargument is considered to come before the value of theotherargument when the 2 values are arranged in order (as defined by the type); it results inBool:falseotherwise. 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 anOrderedsubtype. Note thatis_beforeis considered the only fundamental ordered-specific operator, and all others are defined over it plusis_identical. function sys.Core.Ordered.is_not_before result Bool params { topic(Ordered), other(Ordered) }-
This function is exactly the same as
sys.Core.Ordered.is_beforeexcept that it results in the opposite boolean value when given the same arguments. (It could alternately be called "is after or is identical".) function sys.Core.Ordered.is_inside_range result Bool params { topic(Ordered), min(Ordered), max(Ordered), min_is_inside(Bool), max_is_inside(Bool) }-
This function results in
Bool:trueiff itstopicargument is within the range whose bounds are defined by itsminandmaxarguments. Ifmin_is_insideormax_is_insideareBool:true, thentopicis considered to be within the range if it is equal tominormax, respectively. This function's arguments must be of compatible declared types as persys.Core.Ordered.comparison. This function will fail ifmaxis beforemin. function sys.Core.Ordered.is_outside_range result Bool params { topic(Ordered), min(Ordered), max(Ordered), min_is_inside(Bool), max_is_inside(Bool) }-
This function is exactly the same as
sys.Core.Ordered.is_inside_rangeexcept that it results in the opposite boolean value when given the same arguments. function sys.Core.Ordered.min result Ordered params { topic(SetOfOrdered) }-
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
topichas zero values, thenminresults in the result type's concept of positive infinity, which is the identity value for min. This function will fail on atopicof zero values if the result type's concept of positive infinity is impossible or impractically large to represent, such as with the infiniteTexttype. function sys.Core.Ordered.max result Ordered params { topic(SetOfOrdered) }-
This function is exactly the same as
sys.Core.Ordered.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. function sys.Core.Ordered.maybe_min result MaybeOfOrdered params { topic(SetOfOrdered) }-
This function is exactly the same as
sys.Core.Ordered.minexcept that it results in aMaybeof what is otherwise the result type, and that result has zero elements if the argument has zero elements. function sys.Core.Ordered.maybe_max result MaybeOfOrdered params { topic(SetOfOrdered) }-
This function is to
sys.Core.Ordered.maxassys.Core.Ordered.maybe_minis tosys.Core.Ordered.min.
SYSTEM-DEFINED CORE GENERIC QUASI- FUNCTIONS
This documentation is pending.
SYSTEM-DEFINED CORE CATALOG FUNCTIONS
This documentation is pending.
SYSTEM-DEFINED CORE UPDATERS
Generic Universal
These update operators are applicable to values of any data type at all.
updater sys.Core.Universal.assign update { target(Universal) } read { v(Universal) }-
This update operator will update the variable supplied as its
targetargument so that it holds the value supplied as itsvargument. This update operator's arguments must be of compatible declared types; in this case,vmust be a subtype oftarget.
SYSTEM-DEFINED CORE 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 PROCEDURES
Generic Control-Flow Procedures
These procedures are applicable to use in all kinds of procedures.
procedure sys.Core.Control.fail update {} read { topic(Cat.Exception) }-
This procedure will throw the exception given as its argument; this results in the call stack unwinding, and transaction rollbacks, until it is caught.
procedure sys.Core.Control.try_catch update { try_updating(Tuple), catch_updating(Tuple) } read { try(Cat.NameChain), catch(Cat.NameChain), try_assuming(Tuple), catch_assuming(Tuple) }-
This procedure invokes the procedure named in its
tryargument, giving it the argumentstry_updatingandtry_assumingas itsupdatingandassumingarguments, respectively. If thetryprocedure throws an exception, then any state changes it made roll back (but changes made before that don't), and the call stack unwinds to thetry_catchitself; then the procedure named bycatchis invoked similarly totrywas, with corresponding arguments, but with the extra read-only argumenttopicwhose value is aCat.Exception; if thecatchprocedure also throws an exception (such as to say its not handling the thrown one), then that one is not caught and the call stack unwinding plus applicable transaction rollback carries on to the caller of thetry_catch. If thetryprocedure succeeds (doesn't throw an exception), then thecatchprocedure is not called.
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-2008, Darren Duncan.
See the LICENSE AND COPYRIGHT of Language::MuldisD for details.
ACKNOWLEDGEMENTS
The ACKNOWLEDGEMENTS in Language::MuldisD apply to this file too.