Node:Instance Slots, Next:Class Slots, Up:Accessing Slots
Any slot, regardless of its allocation, can be queried, referenced and set using the following four primitive procedures.
slot-exists? obj slot-name | primitive procedure |
Return #t if obj has a slot with name slot-name,
otherwise #f .
|
slot-bound? obj slot-name | primitive procedure |
Return #t if the slot named slot-name in obj has a
value, otherwise #f .
|
slot-ref obj slot-name | primitive procedure |
Return the value of the slot named slot-name in obj.
|
slot-set! obj slot-name value | primitive procedure |
Set the value of the slot named slot-name in obj to value.
|
GOOPS stores information about slots in class metaobjects. Internally,
all of these procedures work by looking up the slot definition for the
slot named slot-name in the class metaobject for (class-of
obj)
, and then using the slot definition's "getter" and
"setter" closures to get and set the slot value.
The next four procedures differ from the previous ones in that they take
the class metaobject as an explicit argument, rather than assuming
(class-of obj)
. Therefore they allow you to apply the
"getter" and "setter" closures of a slot definition in one class to
an instance of a different class.
[ *fixme* I have no idea why this is useful! Perhaps when a slot in
(class-of obj)
shadows a slot with the same name in one of
its superclasses? There should be an enlightening example here. ]
slot-exists-using-class? class obj slot-name | primitive procedure |
Return #t if the class metaobject class has a slot
definition for a slot with name slot-name, otherwise #f .
|
slot-bound-using-class? class obj slot-name | primitive procedure |
Return #t if applying slot-ref-using-class to the same
arguments would call the generic function slot-unbound , otherwise
#f .
|
slot-ref-using-class class obj slot-name | primitive procedure |
Apply the "getter" closure for the slot named slot-name in
class to obj, and return its result.
|
slot-set-using-class! class obj slot-name value | primitive procedure |
Apply the "setter" closure for the slot named slot-name in
class to obj and value.
|