diff options
Diffstat (limited to 'testsuite/t-proc-with-setter.scm')
-rw-r--r-- | testsuite/t-proc-with-setter.scm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/t-proc-with-setter.scm b/testsuite/t-proc-with-setter.scm new file mode 100644 index 000000000..f6ffe15b0 --- /dev/null +++ b/testsuite/t-proc-with-setter.scm @@ -0,0 +1,20 @@ +(define the-struct (vector 1 2)) + +(define get/set + (make-procedure-with-setter + (lambda (struct name) + (case name + ((first) (vector-ref struct 0)) + ((second) (vector-ref struct 1)) + (else #f))) + (lambda (struct name val) + (case name + ((first) (vector-set! struct 0 val)) + ((second) (vector-set! struct 1 val)) + (else #f))))) + +(and (eq? (vector-ref the-struct 0) (get/set the-struct 'first)) + (eq? (vector-ref the-struct 1) (get/set the-struct 'second)) + (begin + (set! (get/set the-struct 'second) 77) + (eq? (vector-ref the-struct 1) (get/set the-struct 'second)))) |