On Thu, 2 Dec 1999, Bruce Hoult wrote:
> > ... how do I capture an unknown number of multiple return values into a
sequence?
> > listify(values(5,9)) => (5, 9) // a list with two elements
> > listify(values(1,2,3)) => (1, 2, 3) // a list with 3 elements
> > listify(values()) => #() // a list with no elements
>
> OK, I think I'm confused about what you want.
> listify is trivial to write:
> define method listify(#rest args)
> args;
> end method;
You mean
define method listify (#rest args)
as(<list>, args)
end;
since IIRC the type of the #rest argument is <sequence>, not necessarly <list>.
> You can't pass the result of values() to it -- it wants actual arguments.
> You can capture the results of values() into a list with:
> let (#rest x) = values(1,2,3,4);
> If you do this then you don't need listify().
Right, so may be listify should be
define macro listify
{ listify ( ?vals:expression ) }
=> { let (#rest temp) = ?vals;
as(<list>, temp) }
end;
Hugh