[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Ensuring modifiable references within a backquoted template
- To: slug@Warbucks.AI.SRI.COM
- Subject: Ensuring modifiable references within a backquoted template
- From: lgm@ihlpf.att.com
- Date: Mon, 23 Apr 1990 16:11:00 -0400
- Original-from: ihlpf!lgm (Lawrence G Mayka +1 708 713 5166)
I want to initialize multiple variables with a complex list
structure template. The template is mostly constant but has a few
modifiable references. These latter may start out as a constant
value such as NIL but will be changed later (e.g., via PUSH) on a
variable-by-variable basis. The question is how to *ensure* the
proper modifiability, especially in a portable manner. If I
simply quote or backquote the template - e.g.,
'(A (B NIL))
or
`(A (B NIL))
every variable then refers to the same identical template, which
is not what I want. Even "evaluating" (via a comma) the constant
NIL
`(A (B ,NIL))
always yields the identical list structure. On the other hand,
applying the comma to a function call such as
`(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)?
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.
Lawrence G. Mayka
AT&T Bell Laboratories
lgm@ihlpf.att.com
Standard disclaimer.