Records
-------
`(require 'record)'
The Record package provides a facility for user to define their own
record data types.
- Function: make-record-type type-name field-names
Returns a "record-type descriptor", a value representing a new data
type disjoint from all others. The TYPE-NAME argument must be a
string, but is only used for debugging purposes (such as the
printed representation of a record of the new type). The
FIELD-NAMES argument is a list of symbols naming the "fields" of a
record of the new type. It is an error if the list contains any
duplicates. It is unspecified how record-type descriptors are
represented.
- Function: record-constructor rtd [field-names]
Returns a procedure for constructing new members of the type
represented by RTD. The returned procedure accepts exactly as
many arguments as there are symbols in the given list,
FIELD-NAMES; these are used, in order, as the initial values of
those fields in a new record, which is returned by the constructor
procedure. The values of any fields not named in that list are
unspecified. The FIELD-NAMES argument defaults to the list of
field names in the call to `make-record-type' that created the
type represented by RTD; if the FIELD-NAMES argument is provided,
it is an error if it contains any duplicates or any symbols not in
the default list.
- Function: record-predicate rtd
Returns a procedure for testing membership in the type represented
by RTD. The returned procedure accepts exactly one argument and
returns a true value if the argument is a member of the indicated
record type; it returns a false value otherwise.
- Function: record-accessor rtd field-name
Returns a procedure for reading the value of a particular field of
a member of the type represented by RTD. The returned procedure
accepts exactly one argument which must be a record of the
appropriate type; it returns the current value of the field named
by the symbol FIELD-NAME in that record. The symbol FIELD-NAME
must be a member of the list of field-names in the call to
`make-record-type' that created the type represented by RTD.
- Function: record-modifier rtd field-name
Returns a procedure for writing the value of a particular field of
a member of the type represented by RTD. The returned procedure
accepts exactly two arguments: first, a record of the appropriate
type, and second, an arbitrary Scheme value; it modifies the field
named by the symbol FIELD-NAME in that record to contain the given
value. The returned value of the modifier procedure is
unspecified. The symbol FIELD-NAME must be a member of the list
of field-names in the call to `make-record-type' that created the
type represented by RTD.
In May of 1996, as a product of discussion on the `rrrs-authors'
mailing list, I rewrote `record.scm' to portably implement type
disjointness for record data types.
As long as an implementation's procedures are opaque and the `record'
code is loaded before other programs, this will give disjoint record
types which are unforgeable and incorruptible by R4RS procedures.
As a consequence, the procedures `record?', `record-type-descriptor',
`record-type-name'.and `record-type-field-names' are no longer
supported.