Logiweb(TM)

7.8.1 Object creation and destruction

Prev Up Next Page 208 of 800 Search internet


Objects are created by the construct object ( x ) and a destructured into components by destruct ( x ).

Evaluation of object ( ( r :: i ) :: v ) creates an object with tag r :: i and value v. The tag must be a pair of naturals (i.e. natural numbers). We refer to the first natural r as a 'reference' and the the second as an 'index'. Destructuring works the other way in that

destruct ( object ( ( r :: i ) :: v ) ) = ( r :: i ) :: v

The tag is not allowed to have one of the values 0 :: 0, 0 :: 1, 0 :: 2, 0 :: 3, and 0 :: 4 since those tags are reserved for Booleans, integers, pairs, exceptions, and tagged maps, respectively.

Objects allow users to define new data types. Furthermore, objects allow to program new versions of the Logiweb abstract machine which provide built in support for other types than Booleans, integers, pairs, exceptions, and tagged maps. Among other, lgwam badly needs built in support for IEEE floating point numbers, and such support is likely to appear in some, future release of lgwam.

By convention, the reference r and index i of a tag r :: i should be selected as follows:

By convention, when one uses a tag where r is zero and i is a string, the string should be a non-reserved string. A string is reserved if all characters of the string are reserved. A character is reserved if it is a space character or a small letter in the range a to z of the ASCII alphabet. Thus, a string like 'math/kg' is non-reserved because it contains a slash and a string link 'Hello' is non-reserved because it contains a capital letter. Reserved strings are reserved for future extensions of the Logiweb standard. When I need a non-reserved string, I use a slash followed by my initials. Feel free to make your own convention.

Prev Up Next Page 208 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05