|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
util.record- SLIB-compatible record type
This module provides a Guile and SLIB compatible record type API. It is built on top of Gauche’s object system.
gauche.record - Record types, which provides a convenience macro
Returns a new class which represents a new record type.
(It is what is called record-type descriptor in SLIB).
In Gauche, the new class is a subclass of
gauche.record - Record types).
type-name is a string that is used for debugging purposes. It is converted to a symbol and set as the name of the new class. field-names is a list of symbols of the names of fields. Each field is implemented as a slot of the new class.
In the following procedures, rtd is the record class
Returns a procedure that constructs an instance
of the record type of given rtd. The returned
procedure takes exactly as many arguments as field-names,
which defaults to
'(). Each argument sets the initial
value of the corresponding field in field-names.
Returns a procedure that takes one argument, which returns
iff the given argument is of type of rtd.
Returns an accessor procedure for the field named by field-name of type rtd. The accessor procedure takes an instance of rtd, and returns the value of the field.
Returns a modifier procedure for the field named by field-name of type rtd. The modifier procedure takes two arguments, an instance of rtd and a value, and sets the value to the specified field.
(define rtd (make-record-type "my-record" '(a b c))) rtd ⇒ #<class my-record> (define make-my-record (record-constructor rtd '(a b c))) (define obj (make-my-record 1 2 3)) obj ⇒ #<my-record 0x819d9b0> ((record-predicate? rtd) obj) ⇒ #t ((record-accessor rtd 'a) obj) ⇒ 1 ((record-accessor rtd 'b) obj) ⇒ 2 ((record-accessor rtd 'c) obj) ⇒ 3 ((record-modifier rtd 'a) obj -1) ((record-accessor rtd 'a) obj) ⇒ -1
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]|
This document was generated on July 19, 2014 using texi2html 1.82.