Next: syslib structs safe inspect, Previous: syslib structs safe define, Up: syslib structs safe [Index]
Evaluate to the type descriptor of the data structure ?type-name, which
must be the first argument to a previous use of define-struct
.
Return #t
if obj is a struct–type descriptor, otherwise
return #f
. This predicate returns #f
when applied to
R6RS record–type descriptors.
Return a constructor function for struct of type defined by the type descriptor std. The returned constructor accepts as many arguments as there are fields specified by std and it returns a new struct instance.
(define duo-std (make-struct-type "duo" '(one two))) (define make-duo (struct-type-constructor duo-std)) (make-duo 1 2) ⇒ #[struct duo one=1 two=2]
Return a predicate function for structs of type defined by the type descriptor std.
(define duo-std (make-struct-type "duo" '(one two))) (define make-duo (struct-type-constructor duo-std)) (define duo? (struct-type-predicate duo-std)) (duo? (make-duo 1 2)) ⇒ #t
Return an accessor or mutator function for the field at index/name of structs of type defined by the type descriptor std. index/name can be a field index or a symbol representing a field name.
(define-struct color (red green blue)) (define stru (make-color 1 2 3)) ((struct-type-field-accessor (struct-type-descriptor color) 'red) stru) ⇒ 1 ((struct-type-field-accessor (struct-type-descriptor color) 0) stru) ⇒ 1
Return a “method” function for the field at index/name of structs of type defined by the type descriptor std. index/name can be a field index or a symbol representing a field name. When the method function is applied to 1 argument: it behaves like a field accessor. When the method function is applied to 2 arguments: it behaves like a field mutator.
(define-struct color (red green blue)) (define stru (make-color 1 2 3)) (define red-method (struct-type-field-method (struct-type-descriptor color) 'red)) (red-method stru) ⇒ 1 (red-method stru 11) (red-method stru) ⇒ 11
Next: syslib structs safe inspect, Previous: syslib structs safe define, Up: syslib structs safe [Index]