Water 5-Common Data Types-Generic Object and CollectionContract| No input parameters. | | Parameter kind | Default value | Type | | Other unkeyed arguments | opt with ekind of code | | Other keyed arguments | opt | | Water Contract<class thing
_other_keyed=opt=wob="_add_to_environment"
_other_unkeyed=opt=wob="_add_to_environment"
/> | |
See also: vector, wob
If you want to make an object and you don't care what its parent is, use thing.
<thing wieght="heavy" size=12/>
This executes to an object whose parent is thing. It has two additional fields,
a field named "weight" with a value of the string "heavy" and
a field named "size" with the value of the integer 12.
thing allows you to include any keyed arguments in a call to create
an instance of it because the class thing declares _other_keyed=opt,
meaning you can pass in any keyed arguments for a call of thing
and they will be accepted as fields for the new object being made.
A field name can be any object. The object creating syntax permits
integers to be field names:
<thing 0=10.<plus 123/>/>.0
133 <thing 3=10.<plus 124/>/>.3
134
If you want to name the fields by consecutive integers starting with zero,
you can because thing declares _other_unkeyed=opt. So an instance of thing
can behave like a vector:
<thing 100 101 102/>.1
101 <thing 100 101 102/>.<insert 103/>.3
 | 103 |
<thing material="wood" 11 22/>.material
 | "wood" |
<thing material="wood" 11 22/>.1
 | 22 |
Such objects are called "supervectors becuase they behave like vectors
in that they have have non-negative consecutive integer fields,
but they can ALSO have fields whose names are strings as well
as other kinds of field keys.
Doubles can also be names of fields.
<thing 1.2=3.<plus 4/>/>.<get 1.2/>
 | 7 |
Note that dot is used for both floating point numbers and getting the value of a field.
This is unfortunate since it makes dot confusing, but the alternatives weren't
very good either. This is the same as for Java and JavaScript, by the way,
but neither of those can have fields with names of doubles so we have to be careful.
We can't say foo.2.1 and expect to get the field named 2.1 within foo because
instead we'd be asking for the field named 2 in foo and then asking for
the field named 1 within THAT.
<vector 10 11 <vector 508 509/>/>.2.1
 | 509 |
However, we can use get to execute the
name of the field whose value we are asking for. Since numbers execute to themselves,
then foo.<get 2.1/> will get the field named 2.1 in the foo object.
© Copyright 2007 Clear Methods, Inc.