- (modify-location LOC PROC)syntax
Expands into a call to PROC with two arguments: a zero-argument procedure for retrieving the value from the settable location LOC and a one argument procedure for setting the value of LOC. Care is taken to evaluate any subforms in LOC only once.
modify-location is intended to create modification macros for generalized locations (as in SRFI-17.
(define-syntax-rule (increment! loc) (modify-location loc (lambda (ref upd) (upd (add1 (ref)))) ) ) (define x (vector 123)) (increment! (vector-ref x (print 0))) ; sets x to #(124) and prints "0" only once