Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!think!think.com!barmar From: barmar@think.com Newsgroups: comp.lang.lisp Subject: Backquote vs quote (was Re: NCONC & Functions) Message-ID: <31793@news.Think.COM> Date: 29 Nov 89 04:04:24 GMT References: <464@ntcsd1.UUCP> <9893@zodiac.ADS.COM> Sender: news@Think.COM Distribution: na Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 28 In article <9893@zodiac.ADS.COM> rshu@ads.com (Richard Shu) writes: >I guess there's a corollary that says: make sure you create new copies of >lists if that's what you want. Don't use QUOTE (') to cons up data structures. >If you don't like LIST, use the BACKQUOTE macro (`). I've been shafted by >variations of your bug where the problem was using QUOTE instead of BACKQUOTE. You are assuming that backquote always creates new lists. The definition of backquote doesn't say what it produces. It may do as much sharing as it can. In particular, if a backquoted expression contains no comma, then the backquote is equivalent to a quote. An implementation would be justified in translating (defun foo (a) `(,a b c)) into (defun foo (a) (cons a '(b c))) Then (eq (foo) (foo)) => NIL, but (eq (cdr (foo)) (cdr (foo))) => T. And if you NCONC something to the end of (foo) you may change the value of future calls. Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar