From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Filipp Gunbin Newsgroups: gmane.emacs.help Subject: Re: About `macroexpand' Date: Sun, 30 Dec 2012 11:06:46 +0400 Message-ID: <86licg81dl.fsf@w2139spb.ru.yotateam.com> References: <20121230103931.f8b844934dbcf3742fd34e21@gmail.com> <86vcbk8aga.fsf@w2139spb.ru.yotateam.com> <20121230133544.8aca3a27288ec8b408339599@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1356851217 8391 80.91.229.3 (30 Dec 2012 07:06:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Dec 2012 07:06:57 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Xue Fuqiao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 30 08:07:10 2012 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 1TpCzG-0004Zr-DH for geh-help-gnu-emacs@m.gmane.org; Sun, 30 Dec 2012 08:07:10 +0100 Original-Received: from localhost ([::1]:52115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TpCz1-0008UY-Ey for geh-help-gnu-emacs@m.gmane.org; Sun, 30 Dec 2012 02:06:55 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TpCyw-0008UT-Sv for help-gnu-emacs@gnu.org; Sun, 30 Dec 2012 02:06:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TpCyv-0006ja-SE for help-gnu-emacs@gnu.org; Sun, 30 Dec 2012 02:06:50 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:44324) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TpCyv-0006jU-Oi for help-gnu-emacs@gnu.org; Sun, 30 Dec 2012 02:06:49 -0500 Original-Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 0948820598; Sun, 30 Dec 2012 02:06:49 -0500 (EST) Original-Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute2.internal (MEProxy); Sun, 30 Dec 2012 02:06:49 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=mesmtp; bh=5dByre8Hcu5LVmIimRGPjmV eT38=; b=KgwrD1wZBaWNTuYZ2X9LEeO+JSnE+UBp85XO8W8jbSiqwbtg6uXQOU9 +FfyIw/Bvz0ji6E15U3NJiF+/mhOYNfU9TrFTV7Tra4IeeTM/UI0K58/xnCCwJVQ XfI9OaQBqo0KNJpkWrAXImzkb+yLWo5jJJCuJWmIBeattMaVnH/c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:references:date :in-reply-to:message-id:mime-version:content-type; s=smtpout; bh=5dByre8Hcu5LVmIimRGPjmVeT38=; b=LK3swYcd/JqI8IlMgmdOwYTa6Tja v1KnQ/DZu0z2dMBdGnTwC9gvAKH4ok+RPdp+HxAEAkHMs/oeOJ3h1cgNx1eA6TfU 4N2u1INcSw4UINAiFZpxGoi585KCxp0AfFOCnfMjCFnfbc8svKblUmUt1LdiiVaw JgWiozmdGs24uX8= X-Sasl-enc: KZI5qvjtJExJk4Q4Ve1wVbCyGa+l0nGo2aebVufT80Ei 1356851208 Original-Received: from w2139spb.ru.yotateam.com (unknown [94.25.229.80]) by mail.messagingengine.com (Postfix) with ESMTPA id 3D5C948275C; Sun, 30 Dec 2012 02:06:48 -0500 (EST) In-Reply-To: <20121230133544.8aca3a27288ec8b408339599@gmail.com> (Xue Fuqiao's message of "Sun, 30 Dec 2012 13:35:44 +0800") User-Agent: Gnus/5.1299999999999999 (Gnus v5.13) Emacs/24.2 (cygwin) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.111.4.28 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:88345 Archived-At: On 30/12/2012 09:35, Xue Fuqiao wrote: > On Sun, 30 Dec 2012 07:50:45 +0400 > Filipp Gunbin wrote: > >> The comparison doesn't make any sense and what >> is actually overwritten is the local value of `variable'. > > I still don't understand. I tried this: > (defmacro t-becomes-nil (variable) > (list 'if (list 'eq variable t) > (list 'setq variable nil))) > (setq foo t) > (macroexpand '(t-becomes-nil foo)) > > But it returns (if (eq foo t) (setq foo nil))) > What's the difference between these two macros? This version is correct because it returns a form which can be evaluated. The difference between your first and second version is that the first does the (incorrect) computation itself (so macroexpand doesn't return anything) and the second returns the form (and macroexpand shows it) which can be in turn evaluated - and that is a correct macro. The backquote in my example is just a special syntax which helps to avoid complex `(list ...)' constructs with lots of quoting like those you used. -- Filipp Gunbin