[gambit-list] Wills from beyond.
euccastro at gmail.com
Sat Dec 21 21:33:52 EST 2013
In gsi, a will that has become unreachable will still execute when its
testator is about to become unreachable.
What's more, if the will's action is a closure upon some other object, and
if we make that other object unreachable too (such that a different will
with that other object as a testator executes), when the action executes it
will still be able to access that other object. This is probably clearer
> (define o1 (cons 'o 1))
> (define o2 (cons 'o 2))
> (define w1 (make-will o1 (let ((o2_ o2)) (lambda (x) (println "w1 says
bye to " x " but it can still reach " o2_)))))
> (define w2 (make-will o2 (lambda (x) (println "w2 says bye to o2"))))
> (define w3 (make-will w1 (lambda (x) (println "w3 says bye to w1"))))
> (set! w1
w3 says bye to w1
> (set! o2 #f)
w2 says bye to o2
> (set! o1 #f)
w1 says bye to o1 but it can still reach o2
Is this expected semantics, or just accidental behavior that shouldn't be
If o2 was a foreign object with a finalizer, would it have been released by
the time w1 executed, or would w1's closure reference have kept it alive?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gambit-list