/usr/lib/s9fes/help/define-structure is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | S9 LIB (define-structure <name> <slot> ...) ==> unspecific
DEFINE-STRUCTURE creates a new type, which is a sub-type of the vector,
and defines a set of procedures for creating objects of the new type,
accessing its slots, and checking for its type.
<Name> is the name of the new type. Each <slot> defines a slot of the
new type. It must be have one of the following forms:
<slot-name>
(<slot-name>)
(<slot-name> <initial-value>)
<Slot-name> must be a symbol and <initial-value> may be any value.
When an <initial-value> is specified, the correpsonding slot will
be filled with that value whenever a new instance of the structure
is created. When the value is omitted, it defaults to an unspecific
value. <Slot-name> is equal to (<slot-name>).
(define-structure <type> <slot-1> ... <slot-N>) will expand to
definitions of the following procedures:
(<type>? x) is a predicate checking whether X has the type <type>.
(make-<type> object ...) creates a new object of the type <type> and
initializes its slots with the values specified in DEFINE-STRUCTURE.
When some OBJECTs are given, they will replace the default values of
the first slots of the new <type> object. The number of OBJECTs
passed to MAKE-<TYPE> must not be larger than the number of slots
of <type>.
(<type>-copy object) creates an exact copy an object of the given type
and returns it.
(<type>-<slot-1> x) evaluates to the value stored in slot <slot-1>
of X. When X is not of the type <type>, an error will be signalled.
(<type>-<slot-N> x) does the same, but accesses <slot-N>.
(<type>-set-<slot-1>! x v) changes the value stored in slot <slot-1>
of X to V. When X is not of the type <type>, an error will be signalled.
(<type>-set-<slot-N>! x v) does the same, but changes <slot-N>.
(begin
(define-structure point (x 0) (y 0) (color #f))
(let ((p (make-point)))
(point-set-color! p 'yellow)
(list (point? p)
(point-color p)))) ==> (#t yellow)
|