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

[Keith Price <price@usc.edu>: &Rest failure]

    Date: Wed, 8 May 91 10:59:07 PDT
    From: price@usc.edu (Keith Price)

    Does the following behavior make any sense?  It doesn't make any sense to me.

    We ran the following simple test on the original 8.0 world in order to see if
    it was something we did.  It behaves the same on a 3650, 3675, 3645.  We have
    no XL machines.

    Basically, &rest does not seem to work on defun.  (It works on defmacro.)
    This is strange to us since we have many other uses of &rest in defuns that
    work, but today no new compiles or definitions seem to work.

    Command: (defun test (a &rest b) b)
    Command: (test 1 2 3)

	    Keith Price

In Book 7: "Symbolics Common Lisp Language Concepts" (Feb. 1990), read
section 10.4.6, "Safety of &rest Arguments".  The implementation chosen
is to allocate the &rest list on the stack, and is only validly usable
within the dynamic scope of the function.  If you need to return an
&rest arg, copy the list first.  Your test function would become:

(defun test (a &rest b) (copy-list b))