external next up previous contents index
Next: The first verb ``add'': Up: 8.4 MOO tutorialLevel Previous: Creating an object

Creating a property "holding"

Since we want to remember bits of information we now need a place to store them, i.e. a property (slot). Remember that all permanent information is stored in object slots and see section 10.3.1 for more details on property creation: Now, let's create a property (slot) on our new object for that. We name it 'holding' because it will hold some information (this is an arbitrary decision and we could have chosen any other name). Type:

   @property holder.holding {}

This created a property 'holding' with the initial value of ``{}'', i.e. an emptylist. Lists are quite practical and flexible data-structures as you will see later. For now just take it for a fact, that we will use the list attached to the ``holding'' property in order to store bits of information. Type '@d holder.' if you want to be sure that you really added the property you wanted to the object.

Note, that we could have simply typed:

   @property holder.holding
This would have created a property with an initial value of '0'. gif But it is always preferable to initialize a property with the kind of value (see section 10.5.1, page gif) you later want to attach to it, otherwise some verb may break, e.g. you couldn't possible add a number to a string.

In case you forgot to set as initial value as the empty list ``{}'' you are not lost: Just set the value of the property like this:

   @set holder.holding {}

Daniel K. Schneider
Thu Apr 17 12:43:52 MET DST 1997