This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.
Source for wiki ExtendedRecordSyntaxCowan version 1
author
cowan
comment
ipnr
127.11.51.1
name
ExtendedRecordSyntaxCowan
readonly
0
text
This is a proposal for extending the syntax of R7RS record type definitions to accommodate the procedural layer of [http://srfi.schemers.org/srfi-99/srfi-99.html SRFI 99]. It is a reduced version of the SRFI 99 syntactic layer that can be implemented with `syntax-rules`.
== Syntactic Layer ==
The syntactic layer consists of R7RS `define-record-type` extended with single inheritance and mechanisms for abstract record types.
The syntax of a record-type definition is:
{{{
#!html
<pre>
<definition>
-> <record type definition>
<record type definition>
-> (define-record-type <type spec>
<constructor spec>
<predicate spec>
<field spec> ...)
<type spec> -> <type name>
-> (<type name> <parent>)
<constructor spec>
-> #f
-> <constructor name>
-> (<constructor name> <field name> ...)
<predicate spec>
-> #f
-> <predicate name>
<field spec> -> (<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>
</pre>
}}}
The semantics of a record type definition is the same as in R7RS (or SRFI 9, except that record types are generative).
The record type definition macro-expands into a cluster of definitions that:
* define the `<type name>` as the record-type descriptor for the new record-type;
* defines a constructor for instances of the new record-type (unless the constructor spec is `#f`);
* defines a predicate that recognizes instances of the new record-type and its subtypes (unless the predicate spec is `#f`);
* defines an accessor for each field name;
* defines a mutator for each mutable field name.
A record type definition extends SRFI 9 with the following additional options:
* If a `<parent>` expression is specified, then it must evaluate to a record-type descriptor that serves as the parent record-type for the record-type being defined.
* If `#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.)
* If the constructor name is specified as an identifier, then the constructor's arguments correspond to the fields of the parent (if any) followed by the new fields added by this record-type definition in the specified order.
time
2015-04-09 22:38:49
version
1