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

Re: &REST lists



    Date: 11 Mar 1988 16:42-EST
    From: NGALL@g.bbn.com

    2) (This is the one that bothers me.) Some other part of the system
    may modifiy a shared CONS at any time.  This means that although the
    list (chain of CONSes) that is the value of the &REST parameter has
    indefinite extent, some part of the system (e.g., some internal part
    of the function calling mechanism) could modify the CAR or CDR cell of
    any of the CONSes.  For example, I could assign the value of the &REST
    parameter (e.g., the list (1 2 3)) to the special variable *FOO*,
    return from the function, and discover that the value of *FOO* is now
    (1 . !!!END!!!).  The CONS is still there, but someone else (e.g., the
    function-return mechanism) modified its CDR cell.

I don't think that he was suggesting that the conses could be smashed
behind your back by some automatic mechanism like returning from a
function call.  I think the following is an example of the sharing of
&REST lists that may be possible.

(defparameter *shared-list* '(1 2 3))

(defun function-1 (&rest args)
  (function-2)
  (print args))

(defun function-2 ()
  (setf (car *shared-list*) 6))

(defun caller ()
  (apply #'function-1 *shared-list*))

OK, what does (caller) print, (1 2 3) or (6 2 3)?  In Genera it prints
the latter.  Thus, one must be careful when passing argument lists that
can be accessed by other functions.

                                                barmar