previous up next     contents index
Next: Generic Procedures Up: Classes and Objects Previous: Creating Objects

Instance Variable Access

 

  Within a class definition (e.g., within an instance variable's initial value expression), instance variables declared in the class are part of the environment; the instance variable name is used directly to get a value, and set! is used to set an instance variable's value.

Instance variable values are accessed from outside an object with the ivar procedure:  

 
  (ivar [class] object name) 

(Square brackets here indicate optional arguments.) The name is not evaluated: it should be an identifier naming the desired instance variable. Private variables can never be accessed using ivar. If the specified instance variable cannot be found, the  exn:object:ivar exception is raised.

If class is specified, the non-overridden instance variable value is found for the specified class. In this way, the value of an instance variable can be obtained even if it has been overridden in a derived class.

The uq-ivar procedure is like ivar, but the naming argument is evaluated:  

 
  (uq-ivar [class] object name-expr) 

The send abbreviation is useful for invoking methods:  

 
   (send object name arg  tex2html_wrap_inline8722 ) 
    tex2html_wrap_inline8824 
   ((ivar object name) arg  tex2html_wrap_inline8722 ) 




PLT