Next: , Previous: Predefined Classes, Up: Classes


1.3 Record Classes

sos allows generic procedures to discriminate on record types. This means that a record structure defined by means of make-record-type or define-structure can be passed as an argument to a generic procedure, and the generic procedure can use the record's type to determine which method to be invoked.1

In order to support this, sos accepts record type descriptors in all contexts that accept classes. Additionally, every record type descriptor has an associated sos class; either the class or the record type can be used with equivalent results.

— Procedure: record-type-class record-type

Record-type must be a record type descriptor (in other words, it must satisfy the predicate record-type?). Returns the class associated with record-type.

— Procedure: record-class record

Record must be a record (in other words, it must satisfy the predicate record?). Returns the class associated with record. This is equivalent to

          (record-type-class (record-type-descriptor record))
     

Footnotes

[1] If the type option of define-structure is used, the resulting data structure is not a record and thus cannot be used in this manner.