[plt-scheme] Understanding continuations

From: Jos Koot (jos.koot at telefonica.net)
Date: Sun Jul 20 06:06:13 EDT 2008

Where will the value of (lambda (value) (+ 1 2 3 value)) be delivered?
Jos

----- Original Message ----- 
From: "Grant Rettke" <grettke at acm.org>
To: "Jos Koot" <jos.koot at telefonica.net>
Cc: "PLT-list" <plt-scheme at list.cs.brown.edu>
Sent: Sunday, July 20, 2008 3:35 AM
Subject: Re: [plt-scheme] Understanding continuations


> 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.