From: Matthew Flatt <mflatt@cs.utah.edu> Subject: v299.2 Date: Mon, 8 Mar 2004 16:50:32 -0700 The "v299"-tagged code in CVS for MzScheme and MrEd is now version 299.2. Makeshift docs: http://www.cs.utah.edu/~mflatt/tmp/mzscheme-doc.plt http://www.cs.utah.edu/~mflatt/tmp/mred-doc.plt In 299.2, a continuation is no longer tied to its creating thread. (define (stooges) (let ([k #f]) (thread-wait (thread (lambda () (let/ec done (let ([t (let/cc -k (set! k -k) (done))]) (sleep t) (printf "Hellooooo,~n") (sleep (- 2 t)) (printf "Hello!~n") (done) (printf "Shouldn’t get here!~n")))))) (thread (lambda () (k 0))) (thread (lambda () (k 0.5))) (thread (lambda () (k 1))))) (stooges) ; prints "Hello"s Various continuation barriers remain in place, such as around the call to an exception handler or syntax expander, and also around the start of MzScheme’s main thread. In particular, the main thread’s barrier prevents continuations moving into or out of the main thread (because then other threads could become "main"). A newly created thread, however, has no such barrier, so that most threads can trade continuations. In other words, v299.2 really just removes the continuation barrer that use `thread’ used to install. To make thread-independent continuations practical, the "parameter" construct has been redefined, much as we discussed about a year ago. The new definition is indistinguishable from the old one, except that (1) the body of a `parameterize’ is in tail position with respect to the entire `parameterize’ expression, (2) a `parameterize’ expression tends to execute much more quickly, while parameter lookup tends to be slightly slower, (3) a `parameterize’ has the expected effect if a continuation is captured during the `parameterize’ body and invoked in a different thread. Compared to Scsh [see Scheme’02]: * A "parameter" in MzScheme is exactly (I think) a Scsh preserved thread fluid, where MzScheme’s `thread’ is Scsh’s `fork-thread’ (a.k.a `spoon’). * MzScheme doesn’t provide `fluid’ as a separate construct. Parameters are implemented in terms of "preserved thread cells" and continuation marks. Specifically, a continuation’s parameterization is designated by a continuation mark whose value is a mapping from parameters to thread cells. (A new `continuation-mark-set-first’ procedure provides a fast version of `car’ composed with `continuation-mark-set->list’, which is used by the expansion of `parameterize’.) * A "preserved thread cell" is exactly the old "parameter", and plain "thread cells" are now available (as in Scsh). The `make-thread-cell’ procedure takes an optional argument to indicate whether the thread cell is preserved (defaults to #f). Matthew