Next: srfi err5rs records spec iden, Previous: srfi err5rs records spec insp, Up: srfi err5rs records spec [Index]
The syntactic layer consists of SRFI-9 extended with single inheritance and (optional) implicit naming.
All ERR5RS record–type definitions are generative, but ERR5RS drops the SRFI-9 restriction to top level, mainly because the R6RS allows generative definitions wherever a definition may appear.
The (srfi :99 records syntactic)
library exports the
define-record-type
syntax specified below.
The syntax of an ERR5RS record–type definition is:
<definition> -> <record type definition> ; addition to 7.1.6 in R5RS <record type definition> -> (define-record-type <type spec> <constructor spec> <predicate spec> <field spec> ...) <type spec> -> <type name> -> (<type name> <parent>) <constructor spec> -> #f -> #t -> <constructor name> -> (<constructor name> <field name> ...) <predicate spec> -> #f -> #t -> <predicate name> <field spec> -> <field name> -> (<field name>) -> (<field name> <accessor name>) -> (<field name> <accessor name> <mutator name>) <parent> -> <expression> <type name> -> <identifier> <constructor name> -> <identifier> <predicate name> -> <identifier> <accessor name> -> <identifier> <mutator name> -> <identifier> <field name> -> <identifier>
The semantics of a record type definition is the same as in SRFI-9: the record type definition macro–expands into a cluster of definitions that:
<type name>
as the record–type descriptor for the new
record–type;
#f
);
#f
);
An ERR5RS record type definition extends SRFI-9 with the following additional options:
<parent>
expression is specified, then it must evaluate to
an rtd that serves as the parent record–type for the record–type being
defined.
#f
is specified for the constructor or predicate, then no
constructor or predicate procedure is defined. (This is useful when the
record–type being defined will be used as an abstract base class.)
#t
is specified for the constructor or predicate, then the name
of the constructor is the type name prefixed by make-
, and the
name of the predicate is the type name followed by a question mark
(?
).
-
) followed by the field name.
-
) followed by the field name;
-
)
followed by the field name followed by -set!
.
Next: srfi err5rs records spec iden, Previous: srfi err5rs records spec insp, Up: srfi err5rs records spec [Index]