[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

&rest destruction



 
From: Steve Bacher: CSDL
Subject: &rest destruction
 
I see one more potential case where the &rest args may be indestructible - a
possible compiler optimization where, given a function
 
  (defun foo (&rest x) ...)
 
and a call like
 
(foo 'bar 'baz 'frob)
 
the compiler may choose to pass an inline list '(BAR BAZ FROB) to save
on consing.  Guaranteed destructibility would merely enjoin the compiler
writer from generating this optimization, which would probably not be a
problem (although I wouldn't be too happy with such a restriction).
 
(There's one other useful case: if there's a function FROBOZZ,
say, that takes one &REST arg, the compiler should be able to take
 
   (apply #'frobozz some-list)
 
and compile it as a direct call to FROBOZZ, passing the list itself on
as is.  In some architectures this may be much more efficient, even
apart from the elimination of APPLY from the picture; there may be
an INTERNAL-FROBOZZ that takes a single list arg and does the same
thing, in which case the compiler could do a source transform on the
above.  Again, forced consing in this (possibly more frequent) case
could be detrimental.)
 
                                         - Steve