[plt-scheme] unexpected behavior of top level continiuations

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Sat Sep 11 15:33:10 EDT 2004

I tried doing a top level continuation today and ended up with
unexpected behavior.  I was hoping someone could explain to me why
continucations act differnt at top level like:

(define cont #f)
 
(define doom
  (lambda ()
    (display "Doom Doom Doom")
    (call/cc (lambda (cont-internal)
               (set! cont cont-internal)))
    (display "AHHH! My spine!")
    ))
(doom)
(display "this was not in the continiuation")

if you type (cont), it displays "AHHH! My spine!", whereas when using:

(define cont #f)

(define (wrapper) 
(define doom
  (lambda ()
    (display "Doom Doom Doom")
    (call/cc (lambda (cont-internal)
               (set! cont cont-internal)))
    (display "AHHH! My spine!")
    ))
(doom)
(display "this was not in the continiuation"))
(wrapper)

typing (cont) displays "AHHH! My spine! this was not in the continiuation"


Now from what i can gather, R5RS does not have any requirements for
the top level.  In fact R5RS does not require a working scheme
implemenation to be compliant. So I'm forced to wonder, why were
continuations implemented this way in Drscheme, and why is the top
level left out of the R5RS?  is it some deep technical reason, or more
of a apathy issue?



Corey


Posted on the users mailing list.