[Prev][Next][Index][Thread]
Re: small Q
In article <398F745E.33516CAC@worldnet.att.net>, bstewart@bix.com
wrote:
> In fact, it occurs to me that a nice extension to the language would be
> to allow more than two procedures in call-with-values - each procedure's
> (values ..) form would supply arguements to the procedure to its right,
> forming a kind of pipeline. It would certainly be easier to read than
> the normal composition of nested function calls.
In Dylan you need to do this as multiple statements:
let (a, b, c) = foo();
let (d, e) = bar(a, b, c);
let (f, g, h) = baz(d, e);
Not perfect, but more readable than doing it with call-with-values, I
think.
Note that the Dylan isn't quite the same as the Scheme as you have to
name the values. But you get the advantage that you can reorder them,
or only use some of them, or whatever. If it happens that you always
want to use them all in the same order (as above) then you can use #rest
and apply:
let (#rest results) = foo();
let (#rest results) = apply(bar, results);
let (#rest results) = apply(baz, results);
In this case the #rest argument is actually a sequence that can be
passed around, dissected, used with map() etc.
-- Bruce
Follow-Ups:
References: