[previous] [up] [next]     [index]
Next: Object Utilities Up: Instance Variable Access Previous: Instance Variable Access

Generic Procedures

A generic procedure takes an object and extracts an instance variable value from the object. Each generic procedure works on instances of a single class (including instances of classes derived from that class) or interface (i.e., instances of classes that implement the interface) and always extracts the value for the same instance variable.

Generic procedures are provided for efficiency. To extract the value of the same instance variable from multiple objects, it is usually more efficient to create a single generic procedure and use it each time than to use ivar each time. Generic procedures also provide run-time type checking, since a generic procedure only consumes objects of a particular class or interface.

The make-generic/proc procedure creates a generic procedure:

If a generic procedure is applied to an object that is not an instance of the generic procedure's class or interface, the exn:object exception is raised.

The make-generic form expands to an application to make-generic/proc:

  (make-generic ci name) 
   tex2html_wrap_inline100269 
  (make-generic/proc ci (quote name)) 


PLT