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

Portability of ` usage

    Date: Wed, 28 Mar 90 10:58 CST
    From: lgm@ihlpf.att.com

    Our application uses  `   to construct keyword argument lists
    (i.e., property lists) which are then passed around, stored in
    data structures, etc.  I am concerned about the statement in CLtL
    that "...no guarantees are made as to whether the constructed copy
    of the template will or will not share list structure with the
    template itself."  Does this mean that an implementation could
    conceivably rig a  `  expression to return the same list structure
    on each execution, destructively modifying the structure for each
    use of  , ?  For example, consider a function

	    (DEFUN IN-LIST (ARG) `(,ARG))

    Is it really permissible for a Common Lisp implementation to
    return the same (according to EQL) value for these two calls?

	    (IN-LIST 3)

	    (IN-LIST 4)

Of course not, in this example the list would have to be consed afresh each
time.  However, consider this example:

(defun list-with-common-tail (head)
  `(,head foo bar baz))

There is nothing preventing the Lisp implementation from returning a list
whose CDR is the actual constant in the compiled code -- in fact, most
implementations will do this as an optimization.  This means that if you
modify the returned value, you might actually modify the function, depending
on whether the implementation keeps constants in a "read-only" region of
memory or not.

    Symbolics' implementation doesn't do this, of course, but if the
    standard considers it permissible, we may have to modify our usage
    to ensure portability.

	    Lawrence G. Mayka
	    AT&T Bell Laboratories

    Standard disclaimer.

Hope this clarification helps.

 -- Chuck Fry
    Symbolics Software Support