Next: SRFI-18, Previous: SRFI-16, Up: SRFI Support [Contents][Index]
This SRFI implements a generalized set!
, allowing some
“referencing” functions to be used as the target location of a
set!
. This feature is available from
(use-modules (srfi srfi-17))
For example vector-ref
is extended so that
(set! (vector-ref vec idx) new-value)
is equivalent to
(vector-set! vec idx new-value)
The idea is that a vector-ref
expression identifies a location,
which may be either fetched or stored. The same form is used for the
location in both cases, encouraging visual clarity. This is similar
to the idea of an “lvalue” in C.
The mechanism for this kind of set!
is in the Guile core
(see Procedures with Setters). This module adds definitions of
the following functions as procedures with setters, allowing them to
be targets of a set!
,
car
,cdr
,caar
,cadr
,cdar
,cddr
,caaar
,caadr
,cadar
,caddr
,cdaar
,cdadr
,cddar
,cdddr
,caaaar
,caaadr
,caadar
,caaddr
,cadaar
,cadadr
,caddar
,cadddr
,cdaaar
,cdaadr
,cdadar
,cdaddr
,cddaar
,cddadr
,cdddar
,cddddr
string-ref
,vector-ref
The SRFI specifies setter
(see Procedures with Setters) as
a procedure with setter, allowing the setter for a procedure to be
changed, eg. (set! (setter foo) my-new-setter-handler)
.
Currently Guile does not implement this, a setter can only be
specified on creation (getter-with-setter
below).
The same as the Guile core make-procedure-with-setter
(see Procedures with Setters).