Next: rnrs records procedural, Previous: R6RS Records, Up: R6RS Standard Libraries [Contents][Index]
The (rnrs records syntactic (6))
library exports the syntactic
API for working with R6RS records.
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
Evaluates to the record-type descriptor associated with the type specified by record-name.
Evaluates to the record-constructor descriptor associated with the type specified by record-name.
Next: rnrs records procedural, Previous: R6RS Records, Up: R6RS Standard Libraries [Contents][Index]