Hi all, I'm diving slowly into s7, and I stumbled upon this --- (define (inc! x) (format #t "increasing x: ~A" x) (set! x (+ 1 x)) (format #t "x is now ~A" x))
(define x 0) (inc! x) (inc! x) x ;; x is still 0 --- What is my basic misunderstanding here? Of course I could make a pure function (inc x), but I want to know what happens here. I have the vague idea that one could manage to have this inc! function with environments. "box" from chez scheme is more or less the concept i'm going for https://cisco.github.io/ChezScheme/csug9.5/objects.html#./objects:s82 (let ([incr! (lambda (x) (set-box! x (+ (unbox x) 1)))]) (let ([b (box 3)]) (incr! b) (unbox b))) => 4 How does one implement this in s7? Thanks, Christos
_______________________________________________ Cmdist mailing list [email protected] https://cm-mail.stanford.edu/mailman/listinfo/cmdist
