From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Is it possible for a macro to expand to nothing? Date: Mon, 23 Nov 2009 14:09:13 -0800 Message-ID: References: <87r5rpccbh.fsf@galatea.local> <87iqd1c7qn.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1259014479 27598 80.91.229.12 (23 Nov 2009 22:14:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Nov 2009 22:14:39 +0000 (UTC) To: "'Pascal J. Bourguignon'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 23 23:14:32 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NChAx-00032N-PM for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Nov 2009 23:14:28 +0100 Original-Received: from localhost ([127.0.0.1]:60325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NChAx-0000Wl-7g for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Nov 2009 17:14:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NCh6E-0006TR-NH for help-gnu-emacs@gnu.org; Mon, 23 Nov 2009 17:09:34 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NCh6A-0006S9-OG for help-gnu-emacs@gnu.org; Mon, 23 Nov 2009 17:09:34 -0500 Original-Received: from [199.232.76.173] (port=58957 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCh6A-0006Rw-G8 for help-gnu-emacs@gnu.org; Mon, 23 Nov 2009 17:09:30 -0500 Original-Received: from rcsinet11.oracle.com ([148.87.113.123]:28154 helo=rgminet11.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NCh6A-0006HA-3b for help-gnu-emacs@gnu.org; Mon, 23 Nov 2009 17:09:30 -0500 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rgminet11.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nANM9S02001353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Nov 2009 22:09:29 GMT Original-Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nANMBIwt022486; Mon, 23 Nov 2009 22:11:19 GMT Original-Received: from abhmt007.oracle.com by acsmt355.oracle.com with ESMTP id 551332841259014151; Mon, 23 Nov 2009 14:09:11 -0800 Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 23 Nov 2009 14:09:10 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <87iqd1c7qn.fsf@galatea.local> Thread-Index: AcpsgGnKILDWu1bMSAu2WaohRrdTqgABUnCg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: acsmt357.oracle.com [141.146.40.157] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090203.4B0B0814.00BB:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70065 Archived-At: > > Huh? It produces the list ((setq bar 2)), assuming `ifdef' > > acts like `and' > > Yes. And ((setq bar 2)) is not a valid form. Of course it's valid - it's a list. Perhaps you are trying to _evaluate_ it? What you should be evaluating is the entire list that results from macroexpanding the defmacro body. That list is a defun sexp in Alan's case, and there is no problem evaluating it. > So it is not a good idea, not a good style... > > >> This is not a good property. It would be > >> better to keep the contract of macros, that is they take code, and > >> they produce code, that is, valid forms. > > > > No idea what you are talking about. > > Yes, that's the problem. > > > It's simple, really: The code resulting from macroexpansion > > is a list. > > No. CODE resulting from macroexpansion should be CODE. Not > just a list. If you want to get random lists, then use functions, > not macros. The CODE resulting from the macroexpansion here is a _list_ whose car is `defun'. It is a perfectly valid defun expression that can be evaluated without error. It is CODE. But the fact that the body of a defmacro should macroexpand to something that can be evaluated without error is just background info. It is true for all macros. It has nothing to do with the specific question Alan raised. [And BTW, a sexp whose evaluation raises an error is not necessarily "invalid". Validation requires validation against something (e.g. a syntax definition or a specification). Lisp _syntax_ can be said to be invalid if it raises a read-time error. But just because evaluating a sexp raises an error doesn't mean the syntax is invalid. The list (bar) is not "invalid" if evaluating it raises the error that bar's function definition is void.]