From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: Is it possible for a macro to expand to nothing? Date: Tue, 24 Nov 2009 00:55:57 +0000 (UTC) Organization: muc.de e.V. Message-ID: References: <87vdh1ccra.fsf@galatea.local> <87my2dc8d7.fsf@galatea.local> <873a44dcf2.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1259026911 30370 80.91.229.12 (24 Nov 2009 01:41:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Nov 2009 01:41:51 +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 Nov 24 02:41:44 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 1NCkPW-0006PK-Ks for geh-help-gnu-emacs@m.gmane.org; Tue, 24 Nov 2009 02:41:42 +0100 Original-Received: from localhost ([127.0.0.1]:60675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCkPW-0000hD-4O for geh-help-gnu-emacs@m.gmane.org; Mon, 23 Nov 2009 20:41:42 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!kanaga.switch.ch!switch.ch!news.belwue.de!news.tu-darmstadt.de!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 63 Original-NNTP-Posting-Host: marvin.muc.de Original-X-Trace: colin2.muc.de 1259024157 50130 2001:608:1000::2 (24 Nov 2009 00:55:57 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: Tue, 24 Nov 2009 00:55:57 +0000 (UTC) User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.11-RELEASE (i386)) Original-Xref: news.stanford.edu gnu.emacs.help:174999 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:70070 Archived-At: Pascal J. Bourguignon wrote: > "Drew Adams" writes: > This is the problem! Macros shouldn't return a _list_, they should > return a _form_. If you write a macro that returns a list, or you use > it so that it returns a list, that is not a valid form, then it is not > good style, even if you catch up. Is that right? I think you should be required to justify this assertion of "good style". If that "good style" really is good style, then the whole of cc-langs.el (which uses intense macro magic to generate data structures with both compile-time and run-time behaviour) is attrocious style. Fact is, though, it allows a simple tabular writing of constants which vary between C, C++, java, .... Kudos to Martin Stjernholm, who wrote it. >> When the list resulting from macroexpansion is then EVALUATED, yes, of >> course its car must be a defined function, macro, `lambda', etc. (or >> the list must be nil). That is an entirely different matter. That is a >> consideration for _any_ macro one writes. >> In Alan's case, the resulting list has `defun' as its car. It is a >> valid defun expression whose evaluation defines a function. > I don't mind titi, I object to your use of ifdef in titi. That ifdef > call returns a list that is not a valid form. This is not good style. I was more than happy with it. The form was valid, for a reasonable value of "form", and worked. >> The only thing relevant here, AFAICT, is how to create the list Alan >> wants: a list that conditionally contains some element. Backquote plus >> ,@ is the answer. > Yes, since you only want to create a list at that point, do not use a > macro, use a function. Sounds like a fair alternative. Though it's too late at night for my head to work round whether or not a mere function could do the job in the general case. [ .... ] >> Dunno why you do all that. > Because it is a better style. It avoids abusing the ifdef macro. Where does this notion of "abuse" come from? What is its rationale? (This is a genuine question.) >> I'm sure you know what you're talking about, and I know what I'm >> talking about ;-). The only real question is whether either of us >> has actually helped Alan at all. > Well, he has a lot of solutions to choose from now. Indeed, his > situation may not be better :-) Yes, I feel I have been helped. Thank you, both, and good night! -- Alan Mackenzie (Nuremberg, Germany).