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

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

updated records wiki page

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