DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(goops.info.gz) Instance Slots

Info Catalog (goops.info.gz) Accessing Slots (goops.info.gz) Class Slots
 
 Instance Slots
 --------------
 
 Any slot, regardless of its allocation, can be queried, referenced and
 set using the following four primitive procedures.
 
  - primitive procedure: slot-exists? obj slot-name
      Return `#t' if OBJ has a slot with name SLOT-NAME, otherwise `#f'.
 
  - primitive procedure: slot-bound? obj slot-name
      Return `#t' if the slot named SLOT-NAME in OBJ has a value,
      otherwise `#f'.
 
      `slot-bound?' calls the generic function `slot-missing' if OBJ
      does not have a slot called SLOT-NAME ( slot-missing
      Handling Slot Access Errors.).
 
  - primitive procedure: slot-ref obj slot-name
      Return the value of the slot named SLOT-NAME in OBJ.
 
      `slot-ref' calls the generic function `slot-missing' if OBJ does
      not have a slot called SLOT-NAME ( slot-missing Handling
      Slot Access Errors.).
 
      `slot-ref' calls the generic function `slot-unbound' if the named
      slot in OBJ does not have a value ( slot-unbound Handling
      Slot Access Errors.).
 
  - primitive procedure: slot-set! obj slot-name value
      Set the value of the slot named SLOT-NAME in OBJ to VALUE.
 
      `slot-set!' calls the generic function `slot-missing' if OBJ does
      not have a slot called SLOT-NAME ( slot-missing Handling
      Slot Access Errors.).
 
 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. ]
 
  - primitive procedure: slot-exists-using-class? class obj slot-name
      Return `#t' if the class metaobject CLASS has a slot definition
      for a slot with name SLOT-NAME, otherwise `#f'.
 
  - primitive procedure: slot-bound-using-class? class obj slot-name
      Return `#t' if applying `slot-ref-using-class' to the same
      arguments would call the generic function `slot-unbound', otherwise
      `#f'.
 
      `slot-bound-using-class?' calls the generic function
      `slot-missing' if CLASS does not have a slot definition for a slot
      called SLOT-NAME ( slot-missing Handling Slot Access
      Errors.).
 
  - primitive procedure: slot-ref-using-class class obj slot-name
      Apply the "getter" closure for the slot named SLOT-NAME in CLASS
      to OBJ, and return its result.
 
      `slot-ref-using-class' calls the generic function `slot-missing'
      if CLASS does not have a slot definition for a slot called
      SLOT-NAME ( slot-missing Handling Slot Access Errors.).
 
      `slot-ref-using-class' calls the generic function `slot-unbound'
      if the application of the "getter" closure to OBJ returns an
      unbound value ( slot-unbound Handling Slot Access Errors.).
 
  - primitive procedure: slot-set-using-class! class obj slot-name value
      Apply the "setter" closure for the slot named SLOT-NAME in CLASS
      to OBJ and VALUE.
 
      `slot-set-using-class!' calls the generic function `slot-missing'
      if CLASS does not have a slot definition for a slot called
      SLOT-NAME ( slot-missing Handling Slot Access Errors.).
 
Info Catalog (goops.info.gz) Accessing Slots (goops.info.gz) Class Slots
automatically generated byinfo2html