[plt-scheme] continuations problem

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Nov 15 10:22:30 EST 2005

Run it in MzScheme. Or pack it into all into one thunk.

Just to make sure, if you use the reduction semantics of call/cc, the 
first continuation is:

c =

(lambda (_)
  (somehow-define-globally a #f)
  (somehow-define-globally (foo)
    (print 1)
    (call/cc ...)
    (print 3)))

[But the REPL in drscheme won't do this for you.]

Last thought: This looks suspiciously like one of the two Major Puzzles 
in Hitchhiker's Guide to the Meta-Universe. How did you get a copy?

-- Matthias


On Nov 15, 2005, at 10:11 AM, Alex Fritze wrote:

> Continuation novice question:
>
> Can someone explain to me the following behaviour?
>
> (define global-exit #f)
> (call/cc (lambda (c) (set! global-exit c)))
> (define a #f)
> (define (foo)
>  (print 1)
>  (call/cc
>    (lambda (return)
>      (set! a return)
>      (print 2)
>      (global-exit)))
>  (print 3))
> -------------------------------------------------
> Welcome to DrScheme, version 299.400p1.
> > (foo)
> 12
> > (a)
> > (a)
> 3
>
> The first evaluation of (a) yields nothing. The second (and any 
> subsequent ones) yield '3' as I would have expected...
>
> Thanks for any hints,
> Alex
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.