Previous: , Up: iklib records   [Index]


6.19.10 Miscellaneous functions

The following bindings are exported by the library (vicare).

Function: record=? stru

All the arguments must be records. Return #t if all the arguments have the same RTD and equal field values according to equal?. When applied to a single argument: return #t. Note that this function also works when applied to R6RS records.

Function: record!=? stru

All the arguments must be records. Return #t if the arguments are all different: no two arguments are equal according to equal?; otherwise return #f. When applied to a single argument: return #f.

Function: record-reset! record

Reset to void all the fields of a record, whatever its type.

Function: record-object? obj

Return #t if obj is an R6RS record, otherwise return #f. This procedure does not care if the associated record–type is opaque.

Function: record-type-all-field-names rtd

Return a vector holding one Scheme symbol for each field of rtd, including fields of the parents; the order of the symbols is the same of the order of the fields in the rtd definition.

If we need to couple the field names to the field values, we can do it as follows:

(import (vicare))

(define-record-type alpha
  (fields a b c))

(define-record-type beta
  (parent alpha)
  (fields d e f))

(define-record-type gamma
  (parent beta)
  (fields g h i))

(define fields
  (record-type-all-field-names (record-type-descriptor gamma)))

(define O
  (make-gamma 1 2 3 4 5 6 7 8 9))

(let recur ((len (vector-length fields))
            (i   0))
  (if (fx<? i len)
      (cons (list (vector-ref fields i)
                  (struct-ref O i))
            (recur len (fxadd1 i)))
    '())))
⇒ ((a 1) (b 2) (c 3) (d 4) (e 5) (f 6) (g 7) (h 8) (i 9))
Function: record-type-uids-list rtd

Return a list of symbols representing the hierarchy of the record–type rtd.

(define-record-type duo
  (nongenerative user:duo)
  (fields one two))

(record-type-uids-list (record-type-descriptor duo))
⇒ (user:duo
    vicare:scheme-type:<record>
    vicare:scheme-type:<struct>
    vicare:scheme-type:<top>)

Previous: , Up: iklib records   [Index]