chickadee » record-vector » rv-ref

(record-vector-ref R-V #:NAME-k #!optional DEFAULT)procedure
(rv-ref R-V #:NAME-k [#:SUB-NAME-j ...])syntax

This is accesor of the attribute of the record-vector R-V. In CHICKEN record-vector-ref (not the rv-ref) SRFI-17 compatible. Optional DEFAULT value is used if there is no attribute named #:NAME-k.

The rv-ref macro works like record-vector-ref, but if the value with #:NAME-k is a record-vector?, it looks for the value of the #:SUB-NAME-j attribute in it, recursively. The macro does not have a default return value, unlike record-vector-ref.

 
> (record-vector-ref (record-vector #:x 124 #:y 0) #:x) => 124
> (record-vector-ref (make-rv #:x 1) #:t 1900) => 1900
> ;; but no default value in rv-ref macro
> (rv-ref (make-rv #:x 1) #:t 1990) => Error: (cdr) bad argument type: #f
> (rv-ref (make-rv #:person (make-rv #:name "Joe" #:age 50)) #:person #:name ) => "Joe"
;; if attribute is not present it returns False (use rv-attr? predicate before)
> (rv-ref (make-rv #:posn (make-rv #:x 0.0 #:y 0.0)) #:posn #:z) => #f ....