[plt-scheme] continuations problem

From: Alex Fritze (alex at croczilla.com)
Date: Tue Nov 15 10:11:27 EST 2005

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


Posted on the users mailing list.