[Next] [Previous] [Up] [Top] [Contents]

Section 1 - Clauses, Types and Rules

1.8 SDML Objects


There are many times when you want to create many names representing different kinds of things in a model. For example you may want an arbitrary number of consumers (settable in advance). It would be tedious if you had to name them all yourself, so there is a facility to create such unique names in SDML automatically. It is called generatedInstance.

Try the following:

and

inInterval ?uniquifyingTerm 1 100\

generatedInstance ?producer Producer ?uniquifyingTerm

This produces 100 different producer names. In SDML these are called "objects". The second argument (Producer) is the template (called the "type") from which the object is created. So Producer is the type and 'producer-1', 'producer-2' etc. are the instances of this type.

This is a very important idea for understanding SDML. All the work is done by instances, but all the actual programming is done in the types. You can think of a type as a collection of all the properties of its instances.

In the case of simple objects their properties are minimal (they are just a sort of special symbol) but in the case of agents (the universe is one such) they may have many properties including their own definitions, rules and objects.

Try the following:

and

producer ?prod\

inInterval ?i 1 3\

= ?list [?prod ?i]\

generatedInstance ?taxInspector Object "busybody" ?list

This produces three instances of the type Object for each producer, as for each producer there are 3 different bindings ['producer-10' 1], ['producer-10' 2] and ['producer-10' 3] (which happen to be SDML lists). In the above argument we have also made use of the optional argument to determine the prefix part of these generated objects. Despite the fact that we have determined the prefix, the whole name is essentially arbitrary. You should not rely on a particular name being generated for any use.


An introduction to SDML - Bruce Edmonds - 13 JUL 99
[Next] [Previous] [Up] [Top] [Contents]

Generated with CERN WebMaker