[plt-scheme] Understanding continuations

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

This was not very precise:
When (lambda (value) (+ 1 2 3 value)) is called, where does it return the 
value?
Jos

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


> 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))
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme 



Posted on the users mailing list.