[plt-scheme] call/cc and values

From: John Clements (clements at brinckerhoff.org)
Date: Wed Feb 15 15:55:00 EST 2006

On Feb 15, 2006, at 12:44 PM, pedro pinto wrote:

> Hi there,
> Should this work?
> (let/ec return
>   (return (values 1 2)))


> If not, why not?

short answer: because the continuation expects only one argument.

here's another example:

(+ 14 (let/ec return
        (return (values 1 2))))

The only difference is that I wrapped your expression in a (+ 14 ... )

In this instance, it's more obvious that the continuation (that is,  
the "add fourteen to x") is expecting a single value.  But the idea  
is the same.

... but then (you say), why does (values 3 4) work at the top level?

Well, the top level is funny.  And this is one instance in which the  
module-top-level is funny in the same way as mzscheme's top-level,  
essentially (as I understand it) because it's convenient.  Perhaps  
others can give you a better answer.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2430 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20060215/340b7730/attachment.p7s>

Posted on the users mailing list.