From: Ken Tilton
Subject: Re: modifying top level structure in &rest
Date: 
Message-ID: <3458BAA1.585@bway.net>
SDS wrote:
> 
> How dangerous is it to modify the top-level structure of the &rest list?
> CLtL2 p 78 implies that this list is not necessarily new, so what? 

Do /not/ go there! :)

The "correct" approach is to use #'reverse and then see if in real use
it actually causes performance problems. (We just had a nice chate here
about "make it right, then make it efficient".)

Or, if you know up front you'll be hitting this /a lot/, then bite the
bullet and optimize now, by not having Lisp cons for you (unpredictably)
via &rest. ie, cons up the coeffs yourself and pass it as a normal arg:

    (defun npoly (var  coeffs)....)

then

    (npoly aVar (list coeff1 coeff2...))

Call it nPoly to advertise the destructiveness.

If you want /real/ efficiency (increasing program size to minimize
consing) write a macro that loops at compile-time generating code to
handle each argument. Ask again if you need more on this.

Cheers,

  Ken