[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)
    (lambda (return)
      (set! a return)
      (print 2)
  (print 3))
Welcome to DrScheme, version 299.400p1.
 > (foo)
 > (a)
 > (a)

The first evaluation of (a) yields nothing. The second (and any 
subsequent ones) yield '3' as I would have expected...

Thanks for any hints,

Posted on the users mailing list.