Chapter 8:
Miscellaneous Primitives

Evaluation

val: Eany
evlst: [E0 E1 …]
Occasionally, the need arises to evaluate something explicitly. The val primitive does this for you. When used as shown above, a double evaluation actually occurs; the expression Eany is evaluated once by the application and the result is evaluated again explicitly by val.

evlst maps evaluation over a list or stream.

Operations on References

The list-processing virtual machine upon which Daisy is built uses 3-bit tagged pointers (references) for all value representations.

Tag Predicates

You can test for a specific reference tag using one of the predicates below. These predicates are provided for writing language version-specific system software. For general use you are better off using the "sanctioned" type predicates like nil?, list?, etc..
isDCT?:V		=> true if V is a directive, nil otherwise
isFTN?:V		=> true if V is a function cell, nil otherwise
isNML?:V		=> true if V is a number cell, nil otherwise
isIDE?:V		=> true if V is an identifier cell, nil otherwise
isLST?:V		=> true if V is a list cell, nil otherwise
isAPL?:V		=> true if V is an application cell, nil otherwise
isMSG?:V		=> true if V is a message cell, nil otherwise
Please note that these tags are overloaded; two or more primitive data types may be represented using the same tag. For example, a variety of different number types are stored under the NML tag. We do not describe the underlying tag values or data representations in this manual. Furthermore, these tag assignments and representations may change in future versions of Daisy-e.g. a "function" may not be represented using a function tag.

The isMSG? primitive can only be used to detect that something is not an erron. If the argument is an erron, isMSG? returns a new erron. For reliably detecting errons, use the isERR? primitive.

Tag Coercions/Type Conversions

For any given reference or data type, you can obtain a new reference with a compatible alternative tag or an alternative primitive type. Only storage-compatible representations can be tag coerced. For others a new object is generated. If a non-convertible or coercible type is passed an erron is returned.
asDCT:V		=> returns a directive reference or erron
asFTN:V		=> returns a function reference or erron
asNML:V		=> returns a number reference or erron
asIDE:V		=> returns a identifier reference or erron
asLST:V		=> returns a list reference or erron
asAPL:V		=> returns a application reference or erron
asMSG:V		=> returns a message reference or erron

Reference Comparison

cmp?:[V0 V1]	=> true if V0 and V1 resolve to the same reference, nil otherwise
This predicate tells you whether two references are the same (have the same tag and point to the same object). It is very efficient, but should be used carefully. For example,
cmp?:[5 5]
Could return true or nil, depending on whether the interpreter (or compiler) creates two number cells or shares one for the list of fives. For general testing of equality of symbols and numbers, use same? .

System Operations

Daisy has a number of system and "experimental" primitives. These are all prefaced by a percent character.

Garbage Collection

%gc:N => Nfree
%gc invokes a garbage collection. The number returned is the amount of free space recovered in cells.

Timing Operations

%time:N => [Nsec Nusec]
%time takes an integer and returns two integers representing seconds and milliseconds. The exact nature of the values depends on N: Please note that the resolution of the %time function is dependent on the capabilities of the host system.