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

&REST lists



   Date: Mon, 4 Jan 88 21:31 EST
   From: Kent M Pitman <KMP@STONY-BROOK.SCRC.Symbolics.COM>

       Date: Mon, 4 Jan 1988  20:27 EST
       From: "Scott E. Fahlman" <Fahlman@C.CS.CMU.EDU>

	   Is there general agreement on whether it is valid Common Lisp to
	   destructively modify (RPLACA, RPLACD) the list to which a &REST
	   parameter is bound?  I can't find a reference in CLtL for this.

       I think there's general agreement that &rest args are supposed to be
       righteous lists with indefinite extent, so RPLAC'ing them ought to be
       legal.

       ...

   I think TI has already fixed it. Symbolics' Cloe also fixes it.
   Symbolics Genera plans to fix it at some unspecified future date.

   But anyway, the rplaca/rplacd problem is not related to the issue of stack
   allocation. It's the following problem, which comes up in conventional
   architectures as well:

    (DEFVAR *MY-LIST* '(A B C))

    (DEFUN FOO (&REST X) (EQ X *MY-LIST*))

    (APPLY #'FOO *MY-LIST*) => T ;on Symbolics systems and probably
				 ; many stock hardware implementations

   This implies that

    (DEFUN BAR (&REST X) (RPLACA X 'D))

    (APPLY #'BAR *MY-LIST*)

    *MY-LIST* => (D B C) ;on Symbolics systems and probably many stock
			 ; hardware implementations

The Revisedâ??3 Report on Scheme specifies that the equivalent of a
&REST argument must be a newly allocated list, to avoid precisely this
problem.