For Programmers: Free Programming Magazines  


Home > Archive > Scheme > August 2005 > About continuation









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author About continuation
CrazyCorn

2005-08-16, 4:01 am

Hi,I'm new here.
I find a problem when I try to understand continuation with R5RS.
I can't understand why the code below gives the answer -1:

(call-with-values * -)

Could you help me?Thanks a lot.
Anton van Straaten

2005-08-16, 4:01 am

CrazyCorn wrote:
> Hi,I'm new here.
> I find a problem when I try to understand continuation with R5RS.
> I can't understand why the code below gives the answer -1:
>
> (call-with-values * -)
>
> Could you help me?Thanks a lot.


This doesn't really have much to do with continuations specifically.

R5RS defines that (*) returns 1, which is for mathematical reasons.
Call-with-values treats its first argument as a "producer" procedure,
and calls it without arguments. This means that (call-with-values * -)
will first evaluate (*) and obtain the defined answer of 1. It then
applies its "consumer" procedure to this argument, which in this case
means evaluating (- 1). This results in -1.

Anton
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com