Next: , Previous: Pre-Scheme floating point operation, Up: More Pre-Scheme packages


9.4.2 Record types

The ps-record-types structure defines the following special form for introducing record types. Pre-Scheme record types are translated to C as structs.

— syntax: define-record-type
          (define-record-type type type-descriptor
            (constructor argument-field-tag ...)
            (field-tag1 field-type-spec1
              field-accessor1 [field-modifier1])
            (field-tag2 field-type-spec2
              field-accessor2 [field-modifier2])
            ...
            (field-tagn field-type-specn
              field-accessorn [field-modifiern])

Defines a record type. Type is mangled to the C struct type name (type-descriptor-name is unused unless running Pre-Scheme as Scheme). Constructor is defined to construct a record of the new type and initialize the fields argument-type-field ... with its arguments, respectively. If it cannot allocate a sufficient quantity of memory, constructor returns a null pointer. The initial values of fields that are not passed to the constructor are undefined. For each field fieldi specified,

Records must be deallocated explicitly when their lifetime has expired with deallocate.