chickadee » srfi-123 » ref

ref object field #!optional defaultprocedure
~ object field #!optional defaultprocedure

Access value in object specified by field. If there is no such value, signal an error.

~ is the same procedure as ref.

If object is a sparse type, meaning its fields can be "empty" or "unassigned" (such as a hashtable) and the requested field is empty, the value of default is returned, if that argument is supplied, or an error is signaled.

Note that this is an SRFI-17 getter-with-setter, so the value specified by field can be set with:

(set! (ref object field) value)

By default, works on srfi-69 hash-tables, lists/pairs, strings, vectors, srfi-99 records, srfi-4 vectors, and box boxes.