structure(prog_tools) Library Description structure(prog_tools)
NAME
structure - supports C like structures comprised of lymb
objects
DESCRIPTION
This class supports creation of C like structures for data
encapsulation. Messages can be sent to the structures
members by dereferencing them. See the example below. The
structure class uses a hash_table for keeping track of a
structures elements. I think Dave A. wrote this class so
my understanding is a little limited (KM).
SUPERCLASS
object
INSTANCE VARIABLES
MESSAGES
field#structure_element
Dereferences a structure element. All remaining
messages until a semicolon is seen will be sent to
the dereferenced field object.
fields=(`class',`name',`class',`name'
...)
Sets the fields of the structure. See example
below.
fields+(`class',`name',`class',`name'
...)
Adds the fields to the structure.
fields-(`name',`name',
...)
Removes the named fields from the structure.
EXAMPLE
/* create a structure with a scalar and logic field */
structure new: my_struct;
my_struct fields=(`scalar',`x',`logic',`y');
/* now do some simple operations on the structure's members */
my_struct field# x
= 1.5
print:value
;
my_struct field# y
equal: (1.0,1.0)
true: `string new: hammer_time print!;'
;
/* create another structure from the first with an extra field */
my_struct new: my_enhanced_struct
fields+(`string', cool_phrase)
print!
;
my_enhanced_struct field# cool_phrase = `like far out, man!';
SEE ALSO
hash_table
Please send comments and suggestions toconsult@rpi.edu