TEACH SLOTS                                         Steve Knight, May 92

The word "slot" is used consistently in the objectclass library to refer
to an element of an object.  In most object-oriented languages, they
get called "instance variables".  (But that would be an inappropriate
name in lib objectclass because they don't look like variables.)

When you define a class, you can add as many slots as you like.  They

    define :class MyClass;
        slot myName;
        slot myFriend;
    enddefine;

[Note that the keyword "slot" is optional.  I prefer to put it in, but
if you've used -recorclass- for a long while then you might want to
leave it out.]

The slot names become variables.  In this case we invented two slots,
myName and myFriend.  They are initialised to be methods that access
that field of the class

    myName =>
    ** <procedure myName>

Slots get inherited.  This means that when you invent a class, the slots
of all its parents get 'copied' into the new class.

    define :class NewClass;
        is MyClass;
        slot myEnemy;
    enddefine;

In the above case, NewClass ends up with three slots; myName, myFriend,
and myEnemy.  Two of these slots come from the parent class and one from
NewClass.

The whole point about slots is that they allow you to write procedures
(or methods) that can work with a whole family of objects.  Provided the
procedure only accesses slots that the objects have in common,
everything works nicely.  This is what makes inheritance so useful, of
course.

-- See Also -----------------------------------------------------------

REF * OBJECTCLASS/Field Specifications

TEACH * SLOT_DEFAULTS                   On giving slots default values.

-----------------------------------------------------------------------
--- C.all/lib/objectclass/teach/slots
--- Copyright University of Sussex 1993. All rights reserved.
