[plt-scheme] call/cc and values
On Feb 15, 2006, at 12:44 PM, pedro pinto wrote:
> Hi there,
>
> Should this work?
>
> (let/ec return
> (return (values 1 2)))
no.
> 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.
John
-------------- 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>