next up previous contents
Next: Defining new record Up: CHAPTER.9 RECORDSVECTORS Previous: CHAPTER.9 RECORDSVECTORS

Records

A recordclass is a class of objects all of the same general structure, where each object contains zero or more fields that can contain data. A record is an instance of a recordclass. All instances of the same class have the same number of data fields.

Examples of recordclasses that are predefined in Pop-11 are pairs, created by conspair, which are used for lists, and references, created by consref. E.g. all pairs have two fields, all refs have one field.

A field may be "full", i.e. unrestricted in type, and therefore able to contain any legal Pop-11 data-type, or restricted, e.g. to 7 bit integers, or 16 bit decimals, etc.

Each record class has an associated "key" and a family of procedures, as follows:

    o A constructor procedure, for creating new instances (e.g. conspair)
    o An exploder (or destructor) which can be applied to an instance
      and puts all of its contents on the stack (e.g. destpair)
    o A recognizer
    o A collection of accessor/updater procedures, one for each field
      in the recordclass. (For instance pairs have front and back, and
      their updaters.)
    o A class_print procedure for printing instances of the class.
      (The class_print procedure for pairs, knows about printing
      list structures using "[" and "]")
    o A class_apply procedure for deciding what to do if an instance
      is applied to some other object, as if it were a procedure.
      (The class_apply procedure for pairs is invoked if you apply
      a list to an integer N. It returns the N't item of the list.)
Each key is itself an instance of a special recordclass data-type called keys, and its contents provide a lot of information about the class and its instances.

In addition to the class-specific procedures there are generic procedures that can be applied to instances of many different data-types.



Aaron Sloman
Fri Jan 2 03:17:44 GMT 1998