source: project/wiki/eggref/4/records @ 12801

Last change on this file since 12801 was 12801, checked in by felix winkelmann, 12 years ago

copied records wiki page

File size: 2.8 KB
Line 
1[[tag: egg]]
2
3== records
4
5This extension provides a procedural interface to create records, similar
6to the {{define-record}} and {{define-record-type}} ([[http://srfi.schemers.org/srfi-9|SRFI-9]])
7constructs.
8
9=== make-record-type
10
11 [procedure] (make-record-type type-name field-names)
12
13Returns a "record-type descriptor", a value representing a new
14datatype disjoint from all others.  The TYPE-NAME argument must be a
15symbol or a string. The FIELD-NAMES argument is a list of symbols naming the
16"fields" of a record of the new type.  It is an error if the list
17contains any duplicates.
18
19=== record-constructor
20
21 [procedure] (record-constructor rtd [field-names])
22
23Returns a procedure for constructing new members of the type
24represented by RTD.  The returned procedure accepts exactly as many
25arguments as there are symbols in the given list, FIELD-NAMES; these
26are used, in order, as the initial values of those fields in a new
27record, which is returned by the constructor procedure.  The values of
28any fields not named in that list are unspecified.  The FIELD-NAMES
29argument defaults to the list of field names in the call to
30{{make-record-type}} that created the type represented by RTD; if the
31FIELD-NAMES argument is provided, it is an error if it contains any
32duplicates or any symbols not in the default list.
33
34=== record-predicate
35
36 [procedure] (record-predicate rtd)
37
38Returns a procedure for testing membership in the type represented by
39RTD.  The returned procedure accepts exactly one argument and returns
40a true value if the argument is a member of the indicated record type;
41it returns a false value otherwise.
42
43=== record-accessor
44
45 [procedure] (record-accessor rtd field-name)
46
47Returns a procedure for reading the value of a particular field of a
48member of the type represented by RTD.  The returned procedure accepts
49exactly one argument which must be a record of the appropriate type;
50it returns the current value of the field named by the symbol
51FIELD-NAME in that record.  The symbol FIELD-NAME must be a member of
52the list of field-names in the call to {{make-record-type}} that
53created the type represented by RTD.
54
55=== record-modifier
56
57 [procedure] (record-modifier rtd field-name)
58
59Returns a procedure for writing the value of a particular field of a
60member of the type represented by RTD.  The returned procedure accepts
61exactly two arguments: first, a record of the appropriate type, and
62second, an arbitrary Scheme value; it modifies the field named by the
63symbol FIELD-NAME in that record to contain the given value.  The
64returned value of the modifier procedure is unspecified.  The symbol
65FIELD-NAME must be a member of the list of field-names in the call to
66{{make-record-type}} that created the type represented by RTD.
67
68=== Authors
69
70David Carlton, re-written by Aubrey Jaffer, ported to CHICKEN by [[felix winkelmann]]
71
72=== License
73
74Public domain
75
76=== History
77
78; 1.0 : Initial release
Note: See TracBrowser for help on using the repository browser.