[plt-scheme] Re: call/cc vs let/cc at top level - A BUG?
I think you intended for the first and last examples to be the same --
is that right? If so, there is a missing parenthesis at the end of the
let/cc line in the first example (or an extra one in the call/cc
example, I suppose). In any case those two aren't supposed to behave
the same -- in the call/cc example, the printf's are captured in the
continuation, but in the let/cc example, they aren't. Or is there
something else going on here I'm missing?
Robby
On 1/1/07, Kyle Smith <airfoil at bellsouth.net> wrote:
> In the code below you'll find a much leaner set of examples which demonstrate
> the different manner in which call/cc and let/cc handle a simple scenario,
> this time based on a regular variable. I've taken the parameter out of the
> equation, and the difference in behaviour persists. This version of examples
> does not include any of my helper syntax, nor does it try to make the point
> about how the primitive functions for prompts produce consistent behaviour
> across the board. That case was made in my last post regarding this issue.
> This follow up is simply to provide a cleaner demonstration and to make the
> point that it does not seem to have anything to do with parameterization.
>
> Hope you all had a Happy New Year.
>
> --kyle
> airfoil at bellsouth dot net
> schemekeys.blogspot.com
>
> -----------BEGIN CODE EXAMPLES---------------------
>
>
> (define p 1)
> (define cc 'takes-a-continuation)
> (begin
> (call/cc (lambda (k) (set! cc k)))
> (display 'a= )(display p)(newline))
> (display "ONE")(newline)
> (cc 10)
> (display "TWO")(newline)
> (set! p 2)
> (display "THREE")(newline)
> (cc 10)
> (display "~~~~~~~~~~~~~~~~~~~~~~")
> (newline)
> #|
> =>
> a=1
> ONE
> a=1
> TWO
> THREE
> a=2
> ~~~~~~~~~~~~~~~~~~~~~~
> |#
> (collect-garbage)
> (define (a)
> (define p 1)
> (define cc 'takes-a-continuation)
> (begin
> (call/cc (lambda (k) (set! cc k)))
> (display 'a=)(display p)(newline))
> (display "ONE")(newline)
> (cc 10)
> (display "TWO")(newline)
> (set! p 2)
> (display "THREE")(newline)
> (cc 10)
> (display "~~~~~~~~~~~~~~~~~~~~~~")
> (newline)
> )
> (define a-td (thread a))
> (sleep 0.001)
> (kill-thread a-td)
> (sleep 0.1)
> (newline)
> #|
> =>
> a= 1
> 111111111111111111111111111
> a= 1
> 111111111111111111111111111
> ...
> forever
> |#
> (collect-garbage)
> (define (b)
> (define p 1)
> (define cc 'takes-a-continuation)
> (begin
> (let/cc k (set! cc k)
> (display 'b=)(display p)(newline)))
> (display "ONE")(newline)
> (cc 10)
> (display "ONE")(newline)
> (set! p 2)
> (display "ONE")(newline)
> (cc 10)
> (display "~~~~~~~~~~~~~~~~~~~~~~")
> (newline)
> )
> (define b-td (thread b))
> (sleep 0.001)
> (kill-thread b-td)
> (sleep 0.1)
> (newline)
> #|
> b= 1
> ONE
> ONE
> ...
> forever
> |#
>
> (define p 1)
> (define cc 'takes-a-continuation)
> (begin
> (let/cc k (set! cc k)
> (display 'b=)(display p)(newline)))
> (display "ONE")(newline)
> (cc 10)
> (display "TWO")(newline)
> (set! p 2)
> (display "THREE")(newline)
> (cc 10)
> (display "~~~~~~~~~~~~~~~~~~~~~~")
> (newline)
> #|
> =>
> b=1
> ONE
> 10
> TWO
> THREE
> 10
> ~~~~~~~~~~~~~~~~~~~~~~
> |#
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>