Daniel Weinreb <dlw@alum.mit.edu> wrote:
+---------------
| Camm Maguire wrote:
| > As many know, many standard lisp functions require &rest arguments,
| > which are quite slow in a system like GCL which passes arguments on a
| > C stack. ... So I'm trying to live with the &rest, but allow
| > the compiler to eliminate the call to list if the &rest variable
| > is only accessed passively, i.e. via car and the like.
...
| Yeah, it's hard. In the Lisp machine, for a long time, if you
| took a list that was the value of an &rest argument and tried
| to use it longer than the lifetime of the function, it just
| didn't work and you were in real trouble. I think this was
| fixed later but it's hard to remember whether, let alone how,
| it was done.
+---------------
AFAICT, CLHS allows holding onto a &REST parameter's value after
the callee's return... BUT, that might be dangerous anyway due
to the following:
http://alu.org/HyperSpec/Body/sec_3-4-1-3.html
3.4.1.3 A specifier for a rest parameter
...
The value of a rest parameter is permitted, but not required,
to share structure with the last argument to APPLY.
and:
http://alu.org/HyperSpec/Body/fun_apply.html
Function APPLY
...
When the function receives its arguments via &REST, it is
permissible (but not required) for the implementation to bind
the rest parameter to an object that shares structure with the
last argument to APPLY. Because a function can neither detect
whether it was called via APPLY nor whether (if so) the last
argument to APPLY was a constant, conforming programs must
neither rely on the list structure of a rest list to be freshly
consed, nor modify that list structure.
So one must still be careful with it.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607