NAME
Language::MuldisD::Dialect::HDMD_Perl_Tiny - How to format Perl Hosted Data Muldis D
VERSION
This document is Language::MuldisD::Dialect::HDMD_Perl_Tiny version 0.12.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
This document outlines the grammar of the Hosted Data Muldis D dialect named HDMD_Perl_Tiny
. The fully-qualified name of this Muldis D dialect, in combination with the base language spec it is bundled with, is Muldis_D:'cpan:DUNCAND':'N.N.N':'HDMD_Perl_Tiny'
(when the bundled base language version is substituted for the N.N.N
).
This dialect is designed to exactly match the Muldis D system catalog (the possible representation of Muldis D code that is visible to or updateable by Muldis D programs at runtime) as to what non-critical meta-data it explicitly stores; so code in the HDMD_Perl_Tiny
dialect should be round-trippable with the system catalog with the result maintaining all the details that were started with. Since it matches the system catalog, this dialect should be able to exactly represent all possible Muldis D base language code (and probably all extensions too), rather than a subset of it. This dialect similarly matches the PTMD_Tiny
dialect, which is documented at Language::MuldisD::Dialect::PTMD_Tiny.
This dialect is designed to be as small as possible while meeting the above criteria, and is designed such that a parser that handles all of this dialect can be tiny, hence the dialect's Tiny
name. Likewise, a code generator for this dialect from the system catalog can be tiny.
The HDMD_Perl_Tiny
dialect is defined to be hosted in either Perl 5 or Perl 6, and as composed of just|mainly core Perl types. Where Perl 5 and 6 differ, the terminology and examples in this documentation specifically uses Perl 6 terminology and examples by default, and adds analogous Perl 5 terminology as necessary.
Fundamentally, the various Muldis D scalar and collection types are represented by their equivalent Perl 5 or 6 native scalar and collection types. But since Muldis D is more strongly typed, or at least differently typed, than Perl, each Muldis D literal is represented by a Perl Array, whose elements include both the payload Perl literal plus explicit meta-data for how to interpret that Perl literal for mapping to Muldis D.
This document mainly just specifies a way to represent Muldis D values as Perl values. Since the fundamental way to do data definition in Muldis D is to update catalog (information schema) variables, aka the Muldis D meta-model, which are themselves just data, then this document only needs to tell you how to define values to put in the catalog variables. Defining data types or routines are done by defining catalog values describing them.
See instead Language::MuldisD::Core for how to actually define the tuples and relations that define your data types and routines and queries and so forth.
For the present, this document will use the term PHMD (Perl Hosted Muldis D) for brevity when referring to aspects of the Perl-Tiny dialect.
GENERAL STRUCTURE
A PHMD value is composed mainly of a tree of Perl Array, such that each Array is a tree node. The elements of each node/Array include typically a native Perl payload value, which may be a PHMD value itself, plus meta-data for that payload, that meta-data typically including the analogy of a class name, were PHMD nodes instead represented by a tree of PHMD-specific objects. As an exception, one kind of PHMD node is not a Perl Array, but just a Perl Str
; if you see a Str
where you expect a PHMD node, assume it is a Cat.Name
node; this exception is for huffmanizing.
It should be emphasized that no Perl undefined values are allowed anywhere in a PHMD value; you must use only defined values instead. This documentation also assumes that only defined values are used, and that supplying a Perl undef will result in an error. If you genuinely want to represent that a value is unknown or inapplicable, then the Nothing
node type is provided as one way you can explicitly say so. This policy may be reconsidered.
LANGUAGE NAME
As per the VERSIONING pod section of Language::MuldisD, code written in Muldis D must start by declaring the fully-qualified Muldis D language name it is written in. The HDMD_Perl_Tiny
dialect formats this name as a PHMD node having the following 5 elements:
Node type / language base name: the Perl
Str
valueMuldis_D
.Base authority: a Perl
Str
as per the payload of aText
node; typically the PerlStr
valuecpan:DUNCAND
.Base version number: a Perl
Str
as per the payload of aText
node; typically a PerlStr
value like1.2.3
.Dialect: the Perl
Str
valueHDMD_Perl_Tiny
.Extensions: a Perl
Hash|Mapping
as per the payload of aTuple
node.
Examples:
[ 'Muldis_D', 'cpan:DUNCAND', '1.2.3', 'HDMD_Perl_Tiny', {} ]
More specifically, a language name PHMD node like the above would generally be the input for a Perl Hosted Muldis D implementating virtual machine's configuration step, which provides a context for subsequent feeding of other PHMD trees to said virtual machine.
CORE GENERIC SCALAR VALUES
sys.Core.Scalar.Bool
This node type represents a logical boolean value. It has 3 elements:
Node type: the Perl
Str
valueBool
.Format; one of:
md_enum
,perl_bool
,any_perl
.The payload.
This node is interpreted as a Muldis D sys.Core.Scalar.Bool
value as follows:
If the format is
md_enum
, then the payload must be a PerlStr
having one of the valuesfalse
,true
. This format specifically is what the Plain Text Muldis D grammar uses, and is the result of parsing it.If the format is
perl_bool
, then: Under Perl 6, the payload must be a PerlBool
, and soBool::False
andBool::True
are mapped directly. Under Perl 5, the payload must be just the specific result of a Perl 5 logical expression, such as(1 == 0)
or(1 == 1)
, and nothing else; said values are probably the empty string and number 1, respectively.If the format is
any_perl
, then the payload may be any Perl value, and it is simply coerced into a boolean context as per Perl's own semantics; typically for built-in scalars, the empty string and number zero are considered false, and everything else true.
Examples:
[ 'Bool', 'md_enum', 'true' ]
[ 'Bool', 'perl_bool', Bool::False ] # Perl 6 only
[ 'Bool', 'perl_bool', (1 == 0) ]
[ 'Bool', 'perl_any', 42 ]
sys.Core.Scalar.Int
This node type represents an integer value. It has 3-4 elements:
Node type: the Perl
Str
valueInt
.Format; one of:
md_int
,perl_int
,any_perl
.Only when format is
md_int
; the max-col-val.The payload.
This node is interpreted as a Muldis D sys.Core.Scalar.Int
value as follows:
If the format is
md_int
, then the max-col-val must be a PerlStr
composed of a single[1-9A-Z]
character, and the payload must be a PerlStr
of the format0
or\-?<[1-9A-Z]><[0-9A-Z]>*
. This format specifically is what the Plain Text Muldis D grammar uses, and is the result of parsing it. The payload is interpreted as a base-N integer where N might be between 2 and 36, and the given max-col-val says which possible value of N to use. Assuming all column values are between zero and N-minus-one, the max-col-val contains that N-minus-one. So to specify, eg, bases [2,8,10,16], use max-col-val of [1,7,9,F].If the format is
perl_int
, then: Under Perl 6, the payload must be a PerlInt
, which is mapped directly. Under Perl 5, the payload must be just a canonical integer value according to Perl.If the format is
any_perl
, then the payload may be any Perl value, and it is simply coerced into an integer context as per Perl's own semantics, meaning base-10 where applicable. If something doesn't look numeric, it becomes zero; if something looks like a fractional number, it is truncated.
Examples:
[ 'Int', 'md_int', '1', '11001001' ] # binary
[ 'Int', 'md_int', '7', '0' ] # octal
[ 'Int', 'md_int', '7', '644' ] # octal
[ 'Int', 'md_int', '9', '-34' ] # decimal
[ 'Int', 'md_int', '9', '42' ] # decimal
[ 'Int', 'md_int', 'F', 'DEADBEEF' ] # hexadecimal
[ 'Int', 'md_int', 'Z', '-HELLOWORLD' ] # base-36
[ 'Int', 'perl_int', 21 ]
[ 'Int', 'any_perl', ' 171 ' ]
[ 'Int', 'md_int', '3', '301' ] # base-4
[ 'Int', 'perl_int', 0 ]
[ 'Int', 'md_int', 'B', 'A09B' ] # base-12
[ 'Int', 'perl_int', 101 ]
sys.Core.Scalar.Blob
This node type represents a bit string. It has 3-4 elements:
Node type: the Perl
Str
valueBlob
.Format; one of:
md_blob
,perl_blob
.Only when format is
md_blob
; the max-col-val.The payload.
This node is interpreted as a Muldis D sys.Core.Scalar.Blob
value as follows:
If the format is
md_blob
, then the max-col-val must be a PerlStr
composed of a single[137F]
character, and the payload must be a PerlStr
of the format<[0-9A-F]>*
. This format specifically is what the Plain Text Muldis D grammar uses, and is the result of parsing it. Each column of the payload specifies a sequence of one of [1,2,3,4] bits, depending on whether max-col-val is [1,3,7,F].If the format is
perl_blob
, then: Under Perl 6, the payload must be a PerlBlob
, which is mapped directly. Under Perl 5, the payload must be just a canonical Perl bit string, which is a scalar whose utf-8 flag is false.
Examples:
[ 'Blob', 'md_blob', '1', '00101110100010' ] # binary
[ 'Blob', 'md_blob', '3', ''
[ 'Blob', 'md_blob', 'F', 'A705E' # hexadecimal
[ 'Blob', 'perl_blob', (pack 'H2', 'P') ]
[ 'Blob', 'md_blob', '7', '523504376' ]
[ 'Blob', 'perl_blob', (pack 'H2', 'Z') ]
sys.Core.Scalar.Text
This node type represents a character string. It has 2 elements:
Node type: the Perl
Str
valueText
.The payload.
This node is interpreted as a Muldis D sys.Core.Scalar.Text
value by directly mapping the payload. Note that, while Plain Text Muldis D may contain a few escape sequences, those would be replaced with what they represent prior to making a PHMD node. Under Perl 6, the payload must be a Perl Str
, which is mapped directly. Under Perl 5, the payload must be just a canonical Perl character string, which is a scalar whose utf-8 flag is true, or that doesn't contain any octets with a 1
-valued highest bit.
Examples:
[ 'Text', 'Ceres' ]
[ 'Text', 'サンプル' ] # note: Perl 5 needs "use utf8;" pragma to work
[ 'Text', '' ]
[ 'Text', 'Perl' ]
CORE GENERIC NONSCALAR VALUES
sys.Core.Tuple.Tuple
This node type represents a tuple value. It has 2 elements:
Node type: the Perl
Str
valueTuple
.The payload; a Perl
Hash|Mapping
value.
This node is interpreted as a Muldis D sys.Core.Tuple.Tuple
value whose attributes are defined by the payload. Each key+value pair of the payload defines a named attribute of the new tuple; the pair's key and value are, respectively, a Perl Str
that specifies the attribute name, and a PHMD node that specifies the attribute value.
Examples:
[ 'Tuple', {} ]
[ 'Tuple', {
'login_name' => [ 'Text', 'hartmark' ],
'login_pass' => [ 'Text', 'letmein' ],
'is_special' => [ 'Bool', 'md_enum', 'true' ],
} ]
[ 'Tuple', {
'name' => [ 'Text', 'Michelle' ],
'age' => [ 'Int', 'perl_int', 17 ],
} ]
sys.Core.Relation.Relation
This node type represents a relation value. It has 2 elements:
Node type: the Perl
Str
valueRelation
.The payload; a Perl
Array|Seq|Set|KeySet
ofStr|Hash|Mapping
value.
This node is interpreted as a Muldis D sys.Core.Relation.Relation
value whose tuples and attribute names are defined by the payload. Iff the payload has zero elements, then it defines the only relation value having zero attributes and zero tuples. If the payload has elements, then either the elements must all be Str
, or they must all be Hash|Mapping
, but not both kinds in the same payload. Iff a payload's elements are each Str
, then the payload defines the attribute names of a relation having zero tuples; each element must be as per the payload of a Cat.Name
-defining PHMD node. Iff a payload's elements are each Hash|Mapping
, then each element of the payload defines a tuple of the new relation; each element is as per the payload of a tuple-defining PHMD node; every tuple-defining element of the payload must be of the same degree and have the same attribute names as its sibling elements; these are the degree and attribute names of the relation as a whole, which is its heading for the current purposes.
Examples:
[ 'Relation', [] ]
[ 'Relation', [ {}, ] ]
[ 'Relation', [ 'x', 'y', 'z', ] ]
[ 'Relation', [
{
'login_name' => [ 'Text', 'hartmark' ],
'login_pass' => [ 'Text', 'letmein' ],
'is_special' => [ 'Bool', 'md_enum', 'true' ],
},
] ]
[ 'Relation', [
{
'name' => [ 'Text', 'Michelle' ],
'age' => [ 'Int', 'perl_int', 17 ],
},
] ]
sys.Core.Relation.Set
This node type represents a set value. It has 2 elements:
Node type: the Perl
Str
valueSet
.The payload; a Perl
Array|Seq|Set|KeySet
value.
This node is interpreted as a Muldis D sys.Core.Relation.Set
value whose elements are defined by the payload. Each element of the payload defines a unary tuple of the new set; each element is a PHMD node that defines the value
attribute of the tuple.
Examples:
[ 'Set', [
[ 'Text', 'Canada' ],
[ 'Text', 'Spain' ],
[ 'Text', 'Jordan' ],
[ 'Text', 'Thailand' ],
] ]
[ 'Set', [
[ 'Int', 'perl_int', 3 ],
[ 'Int', 'perl_int', 16 ],
[ 'Int', 'perl_int', 85 ],
] ]
sys.Core.Relation.Nothing
This node type represents a 'nothing' value; it is interpreted as a Muldis D sys.Core.Relation.Nothing
. It has 1 element, which is the Perl Str
value Nothing
.
Examples:
[ 'Nothing' ]
sys.Core.Relation.Single
This node type represents a 'single' value. It has 2 elements:
Node type: the Perl
Str
valueSingle
.The payload; a PHMD node that defines a single scalar or nonscalar value.
This node is interpreted as a Muldis D sys.Core.Relation.Single
value whose element is defined by the payload. The payload is a PHMD node that defines the value
attribute of the single tuple of the new 'single'.
Examples:
[ 'Single', [ 'Text', '2003.07.24' ] ]
sys.Core.Relation.Seq
This node type represents a sequence value. It has 2 elements:
Node type: the Perl
Str
valueSeq
.The payload; a Perl
Array|Seq
value.
This node is interpreted as a Muldis D sys.Core.Relation.Seq
value whose elements are defined by the payload. Each element of the payload defines a binary tuple of the new sequence; the element value is a PHMD node that defines the value
attribute of the tuple, and the element index is used as the index
attribute of the tuple.
Examples:
[ 'Seq', [
[ 'Text', 'Alphonse' ],
[ 'Text', 'Edward' ],
[ 'Text', 'Winry' ],
] ]
[ 'Seq', [
[ 'Int', 'perl_int', 57 ],
[ 'Int', 'perl_int', 45 ],
[ 'Int', 'perl_int', 63 ],
[ 'Int', 'perl_int', 61 ],
] ]
sys.Core.Relation.Bag
This node type represents a bag value. It has 3 elements:
Node type: the Perl
Str
valueBag
.Format; one of:
aoa_counted
,array_repeated
,perl_bag
(p6).The payload; a Perl
Bag|KeyBag
value orArray|Seq
orArray|Seq
ofArray|Seq
.
This node is interpreted as a Muldis D sys.Core.Relation.Bag
value whose elements are defined by the payload. The payload is interpreted as follows:
If the format is
aoa_counted
, then the payload must be a PerlArray|Seq
, and each element of the payload defines a binary tuple of the new bag; the element is a 2-elementArray|Seq
, and those 2 elements, by index order, are a PHMD node that defines thevalue
attribute of the tuple, and a 2-3-elementArray|Seq
(which is the same as an 'Int' PHMD node minus the first constant element) that defines thecount
attribute of the tuple; the count must be a positive integer.If the format is
array_repeated
, then the payload must be a PerlArray|Seq
, and each element of the payload contributes to a binary tuple of the new bag; the element value is a PHMD node that defines thevalue
attribute of the tuple. The bag has 1 tuple for every distinct (after format normalization) element value in the payload, and thecount
attribute of that tuple says how many instances of said element were in the payload.If the format is
perl_bag
, then the payload must be a Perl 6 (there is no Perl 5 analogy)Bag|KeyBag
value; the payload elements are PHMD nodes corresponding to thevalue
attribute of the new bag's tuples, and the mapping is as you should expect.
Examples:
[ 'Bag', 'aoa_counted', [
[
[ 'Text', 'Apple' ],
[ 'md_int', '9', '500' ],
],
[
[ 'Text', 'Orange' ],
[ 'perl_int', 300 ],
],
[
[ 'Text', 'Banana' ],
[ 'perl_int', 400 ],
],
] ]
[ 'Bag', 'array_repeated', [
[ 'Text', 'Foo' ],
[ 'Text', 'Quux' ],
[ 'Text', 'Foo' ],
[ 'Text', 'Bar' ],
[ 'Text', 'Baz' ],
[ 'Text', 'Baz' ],
] ]
QUASI-NONSCALAR VALUES
Every PHMD node type for a nonscalar literal has a corresponding extra PHMD node type for a quasi-nonscalar literal. The corresponding extra quasi- node types are exactly the same in format to the non-quasi types but that for each one of them, the value of its first element has the Perl Str
value Quasi
prepended. So PHMD nodes whose first elements each are [QuasiTuple
, QuasiRelation
, QuasiSet
, QuasiNothing
, QuasiSingle
, QuasiSeq
, QuasiBag
] are interpreted as Muldis D [sys.Core.QuasiTuple.QuasiTuple
, sys.Core.QuasiRelation.QuasiRelation
, sys.Core.QuasiRelation.QuasiSet
, sys.Core.QuasiRelation.QuasiNothing
, sys.Core.QuasiRelation.QuasiSingle
, sys.Core.QuasiRelation.QuasiSeq
, sys.Core.QuasiRelation.QuasiBag
] values, respectively.
CATALOG SCALAR VALUES
sys.Core.Cat.Name
This node type represents a canonical short name for any kind of DBMS entity when declaring it; it is a character string type, that is disjoint from Text
.
Unlike every other PHMD node type, a canonical short name is simply a Perl Str
value, which is its payload; it is not encapsulated in a Perl Array; this difference is done for huffmanizing reasons, since a short name is probably the most often used node type, and moreover this change allows for simplifying other parts of the grammar.
This node is interpreted as a Muldis D sys.Core.Cat.Name
value by directly mapping itself / the payload. Note that, while Plain Text Muldis D may contain a few escape sequences, those would be replaced with what they represent prior to making a PHMD node. The node / its payload must be as per the payload of a Text
PHMD node.
Examples:
'login_pass'
'First Name'
sys.Core.Cat.NameChain
This node type represents a canonical long name for invoking some a DBMS entity in some contexts; it is conceptually a sequence of entity short names. It has 2 elements:
Node type: the Perl
Str
valueCat.NameChain
.The payload; a Perl
Array|Seq
value orStr
(char-mode scalar) value.
This node is interpreted as a Muldis D sys.Core.Cat.NameChain
value as follows:
If the payload is an
Array|Seq
, then it must have at least 1 element, and every element must be a valid payload for aCat.Name
PHMD node (that is, any Perl character string). Each element of the payload, in order, defines an element of the sequence possrep of aCat.NameChain
.If the payload is a
Str
, then it must be formatted as a catenation (using period (.
) separators) of at least 1 part, where each part is escaped such that backslashes, single-quotes, and periods are escaped as\b
,\q
and\p
respectively.
Examples:
[ 'Cat.NameChain', ['fed','the_db','gene','sorted_person_name'] ]
[ 'Cat.NameChain', 'fed.the_db.stats.samples_by_order' ]
sys.Core.Cat.Comment
This node type represents the text of a Muldis D code comment; it is a character string type, that is disjoint from both Text
and Name
. It has 2 elements:
Node type: the Perl
Str
valueComment
.The payload.
This node is interpreted as a Muldis D sys.Core.Cat.Comment
value by directly mapping the payload. Note that, while Plain Text Muldis D may contain a few escape sequences, those would be replaced with what they represent prior to making a PHMD node. The payload must be as per the payload of a Text
PHMD node.
Examples:
[ 'Comment', 'This does something.' ]
sys.Core.Cat.E_TK
This node type represents a type kind. It has 2 elements:
Node type: the Perl
Str
valueCat.E_TK
.The payload.
This node is interpreted as a Muldis D sys.Core.Cat.E_TK
value by directly mapping the payload. The payload must be a Perl Str
having one of the 8 values special
, scalar
, tuple
, relation
, quasi_scalar
, quasi_tuple
, quasi_relation
, remnant
.
Examples:
[ 'Cat.E_TK', 'scalar' ]
sys.Core.Cat.E_TDM
This node type represents a type definition method. It has 2 elements:
Node type: the Perl
Str
valueCat.E_TDM
.The payload.
This node is interpreted as a Muldis D sys.Core.Cat.E_TDM
value by directly mapping the payload. The payload must be a Perl Str
having one of the 9 values special
, root
, restriction
, alias
, union
, intersection
, exclusion
, difference
, negation
.
Examples:
[ 'Cat.E_TDM', 'alias' ]
sys.Core.Cat.E_ENK
This node type represents an expression node kind. It has 2 elements:
Node type: the Perl
Str
valueCat.E_ENK
.The payload.
This node is interpreted as a Muldis D sys.Core.Cat.E_ENK
value by directly mapping the payload. The payload must be a Perl Str
having one of the 11 values default
, scalar
, tuple
, relation
, quasi_scalar
, quasi_tuple
, quasi_relation
, param
, upd_param
, ro_param
, func
.
Examples:
[ 'Cat.E_ENK', 'default' ]
sys.Core.Cat.E_PSAK
This node type represents a procedural statement argument kind. It has 2 elements:
Node type: the Perl
Str
valueCat.E_PSAK
.The payload.
This node is interpreted as a Muldis D sys.Core.Cat.E_PSAK
value by directly mapping the payload. The payload must be a Perl Str
having one of the 5 values default
, upd_param
, ro_param
, inner_var
, outer_var
.
Examples:
[ 'Cat.E_PSAK', 'ro_param' ]
RATIONAL EXTENSION SCALAR VALUES
sys.Rational.Rat.Rat
This node type represents a rational value. It has 3-4 elements:
Node type: the Perl
Str
valueRat
.Format; one of:
md_radix
,md_ratio
,md_float
,perl_rat
,perl_float
,perl_int_ratio
,perl_int_float
,any_perl
,any_perl_ratio
,any_perl_float
.Only when format is
md_radix
|md_ratio
|md_float
; the max-col-val.The payload.
This node is interpreted as a Muldis D sys.Rational.Rat.Rat
value as follows:
If the format is
md_radix
, then the max-col-val must be a PerlStr
composed of a single[1-9A-Z]
character, and the payload must be a PerlStr
of the format0
or\-?<[1-9A-Z]><[0-9A-Z]>*\.?<[0-9A-Z]>*
. This format specifically is what the Plain Text Muldis D grammar uses ('radix' option), and is the result of parsing it. The payload is interpreted as a base-N rational where N might be between 2 and 36, and the given max-col-val says which possible value of N to use. Assuming all column values are between zero and N-minus-one, the max-col-val contains that N-minus-one. So to specify, eg, bases [2,8,10,16], use max-col-val of [1,7,9,F].If the format is
md_ratio
, then the max-col-val must be as permd_radix
, and the payload must be a 2-elementArray|Seq
where the first element is a PerlStr
of the format0
or\-?<[1-9A-Z]><[0-9A-Z]>*
(an integer) and the second element is a PerlStr
of the format<[1-9A-Z]><[0-9A-Z]>*
(a positive integer). The payload is interpreted as permd_radix
but that its value comes from the first element (a numerator) divided by the second (a denominator). Note that while themd_radix
format is limited to representing rationals whose denominator is a power of some N between 2 and 36, themd_ratio
format can represent those with any N that is greater than or equal to 2, such as 1/43.If the format is
md_float
, then the max-col-val must be as permd_radix
, and the payload must be a 3-elementArray|Seq
where the first element is a PerlStr
of the format0
or\-?<[1-9A-Z]><[0-9A-Z]>*
(an integer) and the second element is a PerlStr
of the format<[2-9A-Z]><[0-9A-Z]>*
(an integer greater than 1) and the third element is as per the first (an integer). The payload is interpreted as permd_radix
but that its value comes from the first element (a mantissa) multiplied by the result of the second element (a radix) taken to the power of the third (an exponent). Note that while themd_ratio
format can represent all rationals, the very large or very small ones would be quite verbose written in that format, and so themd_float
format allows writing those values in a more terse fashion, such as 1.56*10^37.If the format is
perl_rat
, then: Under Perl 6, the payload must be a PerlRat
(orNum
), which is mapped directly. Under Perl 5, the payload must be just a canonical rational or numeric value according to Perl.If the format is
perl_float
, then: Under Perl 6, the payload must be a PerlFloat
(orNum
), which is mapped directly. Under Perl 5, the payload must be just a canonical floating-point or numeric value according to Perl.If the format is
perl_int_ratio
, then the payload must a 2-elementArray|Seq
where each element must be a canonical integer (or positive integer, respectively) to Perl as per defining aperl_int
; the rational's value is interpreted as the first element divided by the second.If the format is
perl_int_float
, then the payload must a 3-elementArray|Seq
where each element must be a canonical integer (or integer greater than 2, or integer, respectively) to Perl as per defining aperl_int
; the rational's value is interpreted as the first element multiplied by the result of the second element taken to the power of the third.If the format is
any_perl
, then the payload may be any Perl value, and it is simply coerced into a numeric context as per Perl's own semantics, meaning base-10 where applicable. If something doesn't look numeric, it becomes zero.If the format is
any_perl_ratio
, then the payload is as perperl_int_ratio
but that each array element is simply coerced into an integer context. If Perl's coercion of the denominator produces an integer less than 1, it becomes a 1. This may be revised to fail instead.If the format is
any_perl_float
, then the payload is as perperl_int_float
but that each array element is simply coerced into an integer context. If Perl's coercion of the radix produces an integer less than 2, it becomes a 2. This may be revised to fail instead.
Examples:
[ 'Rat', 'md_radix', '1', '-1.1' ]
[ 'Rat', 'md_radix', '9', '-1.5' ] # same val as prev
[ 'Rat', 'md_radix', '9', '3.14159' ]
[ 'Rat', 'md_radix', 'A', '0.0' ]
[ 'Rat', 'md_radix', 'F', 'DEADBEEF.FACE' ]
[ 'Rat', 'md_radix', 'Z', '0.000AZE' ]
[ 'Rat', 'md_ratio', '6', [ '500001', '1000' ] ]
[ 'Rat', 'md_ratio', 'B', [ 'A09B', 'A' ] ]
[ 'Rat', 'md_float', '1', [ '1011101101', '10', '-11011' ] ]
[ 'Rat', 'md_float', '9', [ '45207196', '10', '37' ] ]
[ 'Rat', 'perl_rat', 21.003 ]
[ 'Rat', 'perl_float', 5.428**295 ]
[ 'Rat', 'perl_int_ratio', [ 1, 43 ] ]
[ 'Rat', 'perl_int_float', [ 314159, 10, -5 ] ]
[ 'Rat', 'any_perl', ' 54.67 ' ]
[ 'Rat', 'any_perl_ratio', [ ' 57 ', ' 71 ' ] ]
[ 'Rat', 'any_perl_float', [ ' 656573456 ', ' 8 ', ' 243323 ' ] ]
sys.Rational.Cat.E_RM
This node type represents a rounding method. It has 2 elements:
Node type: the Perl
Str
valueCat.E_RM
.The payload.
This node is interpreted as a Muldis D sys.Rational.Cat.E_RM
value by directly mapping the payload. The payload must be a Perl Str
having one of the 7 values half_down
, half_up
, half_even
, to_floor
, to_ceiling
, to_zero
, to_inf
.
Examples:
[ 'Cat.E_RM', 'half_up' ]
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.