[plt-scheme] Question about call-with-values
At Wed, 30 Oct 2002 13:29:51 -0500, "John W. Small" wrote:
> In the R5RS documentation on page 34 (section 6.4 on
> call-with-values) the following example is given.
>
> (call-with-values (lambda () (values 4 5))
> (lambda (a b) b))
>
> I can achieve the same effect with
>
> (apply (lambda (a b) b) ((lambda () '(4 5))))
>
> I'm trying to think of a more complex example where
> "apply" couldn't synthesize the call-with-values form
> but can't. Is there something special about call-with-values
> that can't be readily achieved with a similar "apply" construct?
Not really, except perhaps detecting when multiple values flow to a
program point that is expecting to receive a single value.
Another potential advantage is that a Scheme implementation can use a
special kind of allocation for a set of results, since the set is not
itself a value. That might help some programs in some Schemes
(including some programs in MzScheme), but it's not clear.
Matthew