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

Ensuring modifiable references within a backquoted template

    Date: Mon, 23 Apr 90 15:11 CDT
    From: lgm@ihlpf.att.com

	    `(A (B ,(IDENTITY NIL))

    indeed results in multiple, safely modifiable list structures.
    Can I depend on this behavior portably, or could a Common Lisp
    implementation thwart my intent by "intelligently"
    constant-folding (IDENTITY NIL) into NIL anyway?  If I were to
    locally declare IDENTITY to be NOTINLINE, would I then be "safe"
    (though slightly slower)?

That should work.  Making IDENTITY notinline requires the implementation
to do the function call.

    I know, of course, that I can use nested LISTs, instead of the
    backquote, to obtain the desired effect; but for sufficiently
    complex list structure, that alternative is markedly inferior to
    the backquote notation.

You could also just use LIST down at the levels you want to be
modifiable, e.g.

	`(A (B . ,(CONS NIL NIL)))

CONS is required to make a new cons every time it is used, so this is
nor permitted to share that cons among different instances.