[plt-scheme] Understanding continuations

From: Grant Rettke (grettke at acm.org)
Date: Sat Jul 19 21:35:13 EDT 2008

On Sat, Jul 19, 2008 at 4:17 AM, Jos Koot <jos.koot at telefonica.net> wrote:
> I suggest you use DrScheme debugger to see what happens with:
>
>> #lang scheme
>> (define cont #f)
>> (define (foo)
>>  (call/cc
>>  (lambda (arg-cont)
>>    (set! cont arg-cont)
>>    13)))
>> (+ 1 2 3 (foo))
>
> (cont 4)
> Do you see why this happens?

It happens because the continuation looks like this:

(lambda (value)
  (+ 1 2 3 value))


Posted on the users mailing list.