BACKQUOTE-COMMA-ATSIGN-DOT-COMMAAPPEND.
The description at the bottom of p350 suggests that `(foo ,@bar) can be legitimately interpreted as any of #1: (list* 'foo bar) #2: (append (list 'foo) bar) #3: (append (list 'foo) bar '()) Unfortunately, issue APPEND-DOTTED has disrupted the equivalences here because if BAR holds a dotted list, #1 and #2 are the same (they preserve the `dotted cdr'), but #3 is different (it replaces the `dotted cdr' with NIL). Under CLtL, a dotted list given to APPEND was an error, so this case did not come up. But since ANSI CL will not make this an error, this ambiguity must be resolved.
LIST* x1 ... xN). The actual (EQL) object xN will be used without copying in the result. The result itself might not be a proper list (e.g., if xN is an atom or dotted list).
Define that `(x1 ... xM ,@xN) is equivalent to (APPEND (LIST 'x1) ... (list 'xM) xN '()). Any top-level list structure of the object xN will be copied in the result, replacing (CDR (LAST xN)) with NIL (or replacing xN itself with NIL if xN is an atom and issue APPEND-ATOM passes).
LIST* x1 ... xN). The actual (EQL) object xN will be used without copying in the result. The result itself might not be a proper list (e.g., if xN is an atom or dotted list).
Define that `(x1 ... xM ,@xN) is equivalent to (APPEND (LIST 'x1) ... (list 'xM) xN). The actual (EQL) object xN will be used without copying in the result. The result itself might not be a proper list (e.g., if xN is an atom or dotted list).
FOO ,@X) may be implemented by either (LIST* 'FOO X) or (APPEND (LIST 'FOO) X '()) or (APPEND (LIST 'FOO) X) A consequence of the proposals above is to distinguish between the two APPEND cases, forcing changes in the side-effect behavior of backquoted structures currently exhibited by some implementations. ;; Issue #1: Non-side-effect treatment of dotted lists.
(LET ((DOTTED (LIST* 'A 'B 'C)))
(VALUES `(FOO ,@DOTTED)
`(FOO . ,DOTTED)))
=> (FOO A B), (FOO A B . C) ;under proposal DIVERGENT => (FOO A B . C), (FOO A B . C) ;under proposal INTERCHANGEABLE
;; Issue #2a: Side-effects
;; Sometimes called the ``Standard Backquote Screw''
;; Structure is unintentionally shared.
(LET ((TAIL1 (LIST 'A 'B 'C))
(TAIL2 (LIST 'A 'B 'C)))
(FLET ((GET-XABC-COMMA-ATSIGN () `(X ,@TAIL1))
(GET-XABC-DOT-COMMA () `(X . ,TAIL2)))
(LET ((TEMP1 (GET-XABC-COMMA-ATSIGN))
(TEMP2 (GET-XABC-DOT-COMMA)))
(SETF (CADDR TEMP1) 'Z)
(SETF (CADDR TEMP2) 'Z)
(VALUES TEMP1 (GET-XABC-COMMA-ATSIGN)
TEMP2 (GET-XABC-DOT-COMMA)))))
=> (X A Z C), (X A B C), (X A Z C), (X A Z C) ;under proposal DIVERGENT
=> (X A Z C), (X A Z C), (X A Z C), (X A Z C) ;under proposal INTERCHANGEABLE
;; Issue #2b: Side-effects
;; Sometimes called ``Inverse Backquote Screw''
;; Structure is unintentionally copied.
(LET ((VAR 'X)
(VAL '7)
(THE-SETQ-TAIL (LIST NIL NIL)))
(LET ((COMMA-ATSIGN `(SETQ ,@THE-SETQ-TAIL))
(DOT-COMMA `(SETQ . ,THE-SETQ-TAIL)))
(SETF (CAR SETQ-TAIL) VAR)
(SETF (CADR SETQ-TAIL) VAL)
(VALUES COMMA-ATSIGN DOT-COMMA)
=> (SETQ NIL NIL), (SETQ X 7) ; under proposal DIVERGENT
=> (SETQ X 7), (SETQ X 7) ; under proposal INTERCHANGEABLE
APPEND-DOTTED and APPEND-ATOM.
Although CLtL tries not to specify the sharing and side-effect implications of backquote, there is no really principled reason for its failure to do so. In practice, the failure to do so leads to gratuitous portability barriers.
APPEND is such that it would be an error to pass it a dotted list, so there is no possibility of discrepancy because the interesting case is an "is an error" case.CL goes into effect.
In practice, since some implementations will have to change incompatibly, some code which accidentally relies on the current behavior will break. However, once such code is fixed, it will be more portable because implementations will not gratuitously diverge.
DIVERGENT makes things slightly harder to learn.
Both proposals make things more predictably portable, which presumably has some aesthetic appeal.
Given that some people already think of ., and ,@ as interchangeable and merely a matter of personal style, it would be better to go with option INTERCHANGEABLE.
TITAN TITAN > 1)
!Î7=élÉ
ºW _¥ú!(zº*start* 01808 00024 US Return-Path: <CL-Cleanup-mailer@SAIL.Stanford.EDU> Redistributed: xerox-cl-cleanup^.pa Received: from SAIL.Stanford.EDU ([36.86.0.194]) by Xerox.COM ; 23 JAN 89 08:20:41 PST Received: from Think.COM by SAIL.Stanford.EDU with TCP; 23 Jan 89 08:20:38 PST Received: from fafnir.think.com by Think.COM; Mon, 23 Jan 89 10:56:42 EST Return-Path: <gls@Think.COM> Received: from verdi.think.com by fafnir.think.com; Mon, 23 Jan 89 11:17:02 EST Received: by verdi.think.com; Mon, 23 Jan 89 11:15:49 EST Date: Mon, 23 Jan 89 11:15:49 EST From: Guy Steele <gls@Think.COM> Message-Id: <8901231615.AA12617@verdi.think.com> To: jonl@lucid.com Cc: masinter.pa, Gray@dsg.csc.ti.com, KMP@stony-brook.scrc.symbolics.com, CL-Cleanup@sail.stanford.edu In-Reply-To: Jon L White's message of Mon, 9 Jan 89 19:54:06 PST <8901100354.AA11931@bhopal> Subject: Issue: BACKQUOTE-COMMA-ATSIGN-DOT-COMMA (Version 1)
Date: Mon, 9 Jan 89 19:54:06 PST From: Jon L White <jonl@lucid.com>
re: The meta-rules for backquote were derived "after the fact" as a way to explain what backquote did; the use of APPEND and the equivalences there were based on the old semantics of APPEND. Now that we've extended APPEND, we have to change the meta-rules of backquote, . . .
Your assumption here can't be true -- The MacLisp implementation (and others) carried out the now-debased optimization; yet the meta-rules stand. I'm very leery of changing these meta rules unless QUUX signs off on it -- every time I've been tempted to dicker with them, I find out that they are much deeper than a cursory glanch would suspect. [I thought Guy devised those "meta" rules -- if he didn't then the author ought to be consulted.]
I am responsible for the meta-rules in CLtL. --Guy