From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Is it possible for a macro to expand to nothing? Date: Sat, 28 Nov 2009 11:25:42 +0100 Organization: Informatimago Message-ID: <874oof54k9.fsf@galatea.local> References: <87my2dc8d7.fsf@galatea.local> <873a44dcf2.fsf@galatea.local> <87pr78b6n9.fsf@galatea.local> <87ljhwb2dx.fsf@galatea.local> <87r5rjwoag.fsf@lion.rapttech.com.au> <87d4335x8t.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1259404908 13879 80.91.229.12 (28 Nov 2009 10:41:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Nov 2009 10:41:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 28 11:41:41 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 1NEKkG-0003f9-QX for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 11:41:41 +0100 Original-Received: from localhost ([127.0.0.1]:38508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NEKkG-0002TS-Bp for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 05:41:40 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 75 Original-X-Trace: individual.net yQuY4uJCgF4ZiySFy9n9UwpCzUOotQz8TJEZHvAwi6P5v+Qq89 Cancel-Lock: sha1:MjI0YTk0MzMyYmM1MzFlZGMzNDU1YTZhZWU3NGI3ZTdhZTNjZGQ4NA== sha1:XLVv5jUWcD/EZzYfw8fZ8dwaQ3U= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Original-Xref: news.stanford.edu gnu.emacs.help:175135 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:70209 Archived-At: Alan Mackenzie writes: > Pascal J. Bourguignon wrote: >> Tim X writes: > >>> On the other hand, Alan's arguments also have merit. If a macro can be >>> useful in generating something other than a form that can be >>> evaluated, such as a data structure and can do so in a way that is >>> cleaner/simpler or just easier to understand than doing the same using >>> functions, then it would make sense. His examples from the C modes >>> seem to be a case in point. > > >> Perhaps Alan's problem with functions comes from the confusion between >> backquote and macros. Since backquote (and , and ,@) are often used in >> macros, some people believe they can be used only in macros, and that >> they ARE what macros are. > > Er, do I actually have a problem with functions? But no, I don't suffer > that particular confusion between backquotes and macros, and have indeed > used backquote when there hasn't been a macro within zeptoparsecs. > >> Far from it! I don't know any language more orthogonal than lisp. > > Maybe not, but even lisp only gets to about 89 degrees. It is missing an > operator which does the same as ,@ outside backquote. This is one of the > lacks which makes it so difficult to write an equivalent of C's #if. Yes, emacs lisp is missing reader macros. In Common Lisp there's #+, #- and #., and reader macros may return 0 object. >> Backquote can be used in a function to build a s-exp (including part of >> a form) as it can be used anywhere. > >> Therefore it is really not easier to use macros to generate parts of a >> form than function. > > It is if you need "side effects", like c-lang-defconst and friends do. Well, I'm not sure about emacs, but in the case of Common Lisp, you have to be careful with side effects in macros, because it is not specified how many times, and when, macro functions are called. I'd say that with emacs you at least have the same problem if you load and/or eval the contents of a file and then you byte-compile it, the macros may be executed twice. So that's one more difficulty you have to cater to with macros, that you don't have with functions. > [ Stuff read and appreciated. My brain's not up to it so early in the > morning]. > >> If you wanted to use macros, in addition to the complexity of having >> to use macroexpand to use it, you would have the difficulty of passing >> the parameters, since a macro gets it's parameters from the source >> form. In the case of a function, you have the choice to quote or not >> to quote the parameters, with macros they're always quoted for you. > > In the case of a function, you've GOT to quote, which can get very > tedious in some circumstances. That's probably the reason that Martin > Stjernholm wrote c-lang-const etc. as macros. Read again my example, I hadn't to quote the arguments to the function because they weren't the literal arguments, but variables containing the arguments, because the function was called from another function or macro (macro in this case) who got them as parameter. If you had to forward arguments to a macro, it would be much more complicated. Then you would have to use macroexpand. -- __Pascal Bourguignon__