manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6.2.9 rnrs records syntactic

The (rnrs records syntactic (6)) library exports the syntactic API for working with R6RS records.

Scheme Syntax: define-record-type name-spec record-clause …

Defines a new record type, introducing bindings for a record-type descriptor, a record constructor descriptor, a constructor procedure, a record predicate, and accessor and mutator procedures for the new record type’s fields.

name-spec must either be an identifier or must take the form (record-name constructor-name predicate-name), where record-name, constructor-name, and predicate-name are all identifiers and specify the names to which, respectively, the record-type descriptor, constructor, and predicate procedures will be bound. If name-spec is only an identifier, it specifies the name to which the generated record-type descriptor will be bound.

Each record-clause must be one of the following:

  • (fields field-spec*), where each field-spec specifies a field of the new record type and takes one of the following forms:
    • (immutable field-name accessor-name), which specifies an immutable field with the name field-name and binds an accessor procedure for it to the name given by accessor-name
    • (mutable field-name accessor-name mutator-name), which specifies a mutable field with the name field-name and binds accessor and mutator procedures to accessor-name and mutator-name, respectively
    • (immutable field-name), which specifies an immutable field with the name field-name; an accessor procedure for it will be created and named by appending record name and field-name with a hyphen separator
    • (mutable field-name), which specifies a mutable field with the name field-name; an accessor procedure for it will be created and named as described above; a mutator procedure will also be created and named by appending -set! to the accessor name
    • field-name, which specifies an immutable field with the name field-name; an access procedure for it will be created and named as described above
  • (parent parent-name), where parent-name is a symbol giving the name of the record type to be used as the parent of the new record type
  • (protocol expression), where expression evaluates to a protocol procedure which behaves as described above, and is used to create a record constructor descriptor for the new record type
  • (sealed sealed?), where sealed? is a boolean value that specifies whether or not the new record type is sealed
  • (opaque opaque?), where opaque? is a boolean value that specifies whether or not the new record type is opaque
  • (nongenerative [uid]), which specifies that the record type is nongenerative via the optional uid uid. If uid is not specified, a unique uid will be generated at expansion time
  • (parent-rtd parent-rtd parent-cd), a more explicit form of the parent form above; parent-rtd and parent-cd should evaluate to a record-type descriptor and a record constructor descriptor, respectively
Scheme Syntax: record-type-descriptor record-name

Evaluates to the record-type descriptor associated with the type specified by record-name.

Scheme Syntax: record-constructor-descriptor record-name

Evaluates to the record-constructor descriptor associated with the type specified by record-name.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2019
Individual documents may contain additional copyright information.