[plt-scheme] Continuations and (begin)
2009/2/7 Matthew Flatt <mflatt at cs.utah.edu>
> At Sat, 7 Feb 2009 13:34:38 +0000, James Coglan wrote:
> > (begin
> > (call/cc
> > (lambda (k)
> > (set! r k)
> > #t))
> > (set! count-calls (+ count-calls 1)))
> > (r #t) (r #t) (r #t)
> >
> > I would expect count-calls to equal 4 after this, but it equals 1. The
> > continuation, from what little I've read about this, should look like:
> >
> > ([#procedure] [#hole] (set! count-calls (+ count-calls 1)))
>
> The body of a top-level `begin' is spliced into the top-level sequence,
> so the `begin' above doesn't usefully group the two expressions. (To
> put it another way, a top-level `begin' wraps a prompt around each of
> its sub-expressions.)
Thanks. Just out of curiosity, is there a function that simply returns the
current continuation without jumping to another function using (call/cc)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090207/646f88c8/attachment.html>