[r6rs-discuss] [Formal] SRFI-39 should be made an R6RS library
> OK, thanks for clarifying. Does this mean that, if you capture an
> escape procedure inside a dynamic binding, and you invoke that escape
> procedure in a different thread, the thread where the escape procedure
> is invoked will see a different value when it dereferences the
> parameter than the capturing thread?
No. Whether the continuation is invoked by the same or a different
thread, the value will be the same as the one in place when the
continuation was created. Here's an example:
(let ([child-k #f] [p (make-thread-parameter 0)])
(fork-thread
(lambda ()
(set! child-k
(parameterize ([p 1])
((call/cc
(lambda (k)
(lambda () k))))))))
(write (p))
(let f () (unless child-k (f)))
(call/cc
(lambda (k)
(child-k (lambda () (write (p)) (k)))))
(write (p)))
This writes 010. All three writes are performed by the main thread,
which never parameterizes p. The first and third writes are performed
outside of any parameterization of p and thus print the initial value, 0.
The second write prints 1, however, because that's the value of p at the
point where the continuation child-k is created, and the thunk passed
to child-k is invoked in that continuation.
Kent
Received on Thu Feb 15 2007 - 16:50:34 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:01 UTC