Next: iklib records final, Previous: iklib records predicates, Up: iklib records [Index]
As defined by R6RS, this function accepts only two arguments and the second is a relative field index; record-accessor. Vicare extends this function.
The argument index/name can be either a relative field index, as specified by R6RS, or a symbol representing a field name. In the second case rtd and its parents are searched for the first matching field specification, so fields of the sub–types take precedence.
The optional third argument accessor-who must be a symbol representing the name of the returned accessor function; it is used for descriptive error reporting.
Here is an example with the field name argument being a symbol:
(import (vicare)) (define-record-type alpha (fields a b c)) (define alpha-rtd (record-type-descriptor alpha)) (define R (make-alpha 1 2 3)) ((record-accessor alpha-rtd 'a) R) ⇒ 1 ((record-accessor alpha-rtd 'b) R) ⇒ 2 ((record-accessor alpha-rtd 'c) R) ⇒ 3
Below is another example with record type inheritance; notice that both the record types have a field named ‘C’ and the sub–type takes precedence:
(import (vicare)) (define-record-type alpha (fields a b C)) (define-record-type beta (parent alpha) (fields C d e)) (define beta-rtd (record-type-descriptor beta)) (define R (make-beta 1 2 3 4 5 6)) ((record-accessor beta-rtd 'a) R) ⇒ 1 ((record-accessor beta-rtd 'b) R) ⇒ 2 ((record-accessor beta-rtd 'C) R) ⇒ 4 ((record-accessor beta-rtd 'd) R) ⇒ 5 ((record-accessor beta-rtd 'e) R) ⇒ 6
As defined by R6RS, this function accepts only two arguments and the second is a relative field index; record-mutator. Vicare extends this function.
The argument index/name can be either a relative field index, as specified by R6RS, or a symbol representing a field name. In the second case rtd and its parents are searched for the first matching field specification, so fields of the sub–types take precedence.
The optional third argument mutator-who must be a symbol representing the name of the returned mutator function; it is used for descriptive error reporting.
Here is an example with the field name argument being a symbol:
(import (vicare)) (define-record-type alpha (fields a b c)) (define alpha-rtd (record-type-descriptor alpha)) (define R (make-alpha 1 2 3)) ((record-mutator alpha-rtd 'a) R 19) ((record-mutator alpha-rtd 'b) R 29) ((record-mutator alpha-rtd 'c) R 39) ((record-accessor alpha-rtd 'a) R) ⇒ 1 ((record-accessor alpha-rtd 'b) R) ⇒ 2 ((record-accessor alpha-rtd 'c) R) ⇒ 3
and another example with record type inheritance; notice that both the record types have a field named ‘C’ and the sub–type takes precedence:
(import (vicare)) (define-record-type alpha (fields a b C)) (define-record-type beta (parent alpha) (fields C d e)) (define beta-rtd (record-type-descriptor beta)) (define R (make-beta 1 2 3 4 5 6)) ((record-mutator beta-rtd 'a) R 19) ((record-mutator beta-rtd 'b) R 29) ((record-mutator beta-rtd 'C) R 49) ((record-mutator beta-rtd 'd) R 59) ((record-mutator beta-rtd 'e) R 69) ((record-accessor beta-rtd 'a) R) ⇒ 19 ((record-accessor beta-rtd 'b) R) ⇒ 29 ((record-accessor beta-rtd 'C) R) ⇒ 49 ((record-accessor beta-rtd 'd) R) ⇒ 59 ((record-accessor beta-rtd 'e) R) ⇒ 69
Like record-accessor
, but return an unsafe field accessor that
will not validate its arguments.
Like record-mutator
, but return an unsafe field mutator that will
not validate its arguments.
Return the value of the field at absolute index index for the record reco.
Next: iklib records final, Previous: iklib records predicates, Up: iklib records [Index]