From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: understanding backquote Date: Tue, 02 Jun 2015 17:22:01 -0400 Organization: A noiseless patient Spider Message-ID: References: <87vbf65jem.fsf@free.fr> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1433280327 27787 80.91.229.3 (2 Jun 2015 21:25:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Jun 2015 21:25:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 02 23:25:22 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YztgV-00063v-CY for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Jun 2015 23:25:19 +0200 Original-Received: from localhost ([::1]:60962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YztgU-0000zM-Dw for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Jun 2015 17:25:18 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!barmar.motzarella.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 49 Injection-Info: barmar.motzarella.org; posting-host="2be9e9f5dd9af768b8861af71b85fc28"; logging-data="4183"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19X0I+UWECmXK8oRYazEX93" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:WPCdyXnFLQc4eNBdKePDm9voUno= Original-Xref: usenet.stanford.edu gnu.emacs.help:212437 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104721 Archived-At: In article , Olaf Rogalsky wrote: > Hi, > > I have problems in understanding the semantics of backquote. Consider > the following function: > > (defun test () `,(* (+ 1 2) (+ 3 4))) > > Now let's have a look at the defintion of the symbol: > > (symbol-function 'test) > => (lambda nil (* (+ 1 2) (+ 3 4))) > > Huhh??? I was thinking, that the above definition is equivalent to the > following: > > (defun test () 21) > > Ok, this was unexpected, but perhaps the compiler does it "right": > (disassemble (byte-compile 'test)) > => byte code: > args: nil > 0 constant 21 > 1 return > > Yes, it does. It is only, that I suspect, that this has nothing to do > with backquotes, but rather with constant folding optimization. > > Can anybody explain this to me? Backquote and comma operate at read time. The comma means "Don't quote this part", so it will be evaluated when the code is run. It doesn't get evaluated at read time, though, because that would mess up if it has variable references, e.g. (defun test (a) `,(+ 1 a)) If you looked at this function, it would have to be (lambda (a) (+ 1 a)) It can't be folded at read time. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***