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>
 &lt;definition&gt;           
   -&gt; &lt;record type definition&gt;

 &lt;record type definition&gt;
   -&gt; (define-record-type &lt;type spec&gt;
        &lt;constructor spec&gt;
        &lt;predicate spec&gt;
        &lt;field spec&gt; ...)

 &lt;type spec&gt;  -&gt; &lt;type name&gt;
              -&gt; (&lt;type name&gt; &lt;parent&gt;)

 &lt;constructor spec&gt;
              -&gt; #f
              -&gt; &lt;constructor name&gt;
              -&gt; (&lt;constructor name&gt; &lt;field name&gt; ...)

 &lt;predicate spec&gt;
              -&gt; #f
              -&gt; &lt;predicate name&gt;

 &lt;field spec&gt; -&gt; (&lt;field name&gt; &lt;accessor name&gt;)
              -&gt; (&lt;field name&gt; &lt;accessor name&gt; &lt;mutator name&gt;)

 &lt;parent&gt;           -&gt; &lt;expression&gt;

 &lt;type name&gt;        -&gt; &lt;identifier&gt;
 &lt;constructor name&gt; -&gt; &lt;identifier&gt;
 &lt;predicate name&gt;   -&gt; &lt;identifier&gt;
 &lt;accessor name&gt;    -&gt; &lt;identifier&gt;
 &lt;mutator name&gt;     -&gt; &lt;identifier&gt;
 &lt;field name&gt;       -&gt; &lt;identifier&gt;
</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