mit-scheme-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MIT-Scheme-devel] call-with-values requires thunk to use 'values'?


From: Joe Marshall
Subject: Re: [MIT-Scheme-devel] call-with-values requires thunk to use 'values'? Why?
Date: Tue, 14 Dec 2010 08:09:33 -0800

On Sun, Dec 12, 2010 at 8:25 PM, Daniel Katz <address@hidden> wrote:
>
> but when I look at R5RS, there doesn't seem to be anything in the
> description of call-with-values that would require the use of 'values'
> to return the values from the first argument to call-with-values.

Unfortunately, the restriction is implied in two earlier sentences.
Under the definition of call-with-current-continuation, it says
``The effect of passing no value or more than one value to
  continuations that were not created by call-with-values is
  unspecified.''

>  In fact, R5RS even gives an example where that's not true 
> (http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_idx_574):
>
> (call-with-values * -) ===> -1

The examples are non-normative.


>
> Is this just a 'yet to be finished' area of R5RS compliance
> for MIT-scheme?

It is working as intended.

>   Or is there some particular reason why
> the 'values' requirement on 'call-with-values' has been
> imposed?

There are two rationales.  First, since a continuation is a procedure,
it seems to make sense to perform the same arity checking one
would normally perform.  Second, it permits implementations that
do not natively support multiple values to define `values' as
 (lambda vals (lambda (receiver) (apply receiver vals)))

In my opinion, though, the Common Lisp approach (a single
return value is the same whether you use `values' or not, arity
is not checked, extra values are silently dropped) is much
more useful.

-- 
~jrm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]