From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.help Subject: Re: Is it possible for a macro to expand to nothing? Date: Sat, 28 Nov 2009 13:57:44 +0100 Organization: ThierryVolpiatto Message-ID: <87ljhqyfg7.fsf@tux.homenetwork> 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> <874oof54k9.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 1259413561 2339 80.91.229.12 (28 Nov 2009 13:06:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Nov 2009 13:06:01 +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 14:05:54 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 1NEMzp-0007T7-Kh for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 14:05:54 +0100 Original-Received: from localhost ([127.0.0.1]:50734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NEMzp-0002Ab-B7 for geh-help-gnu-emacs@m.gmane.org; Sat, 28 Nov 2009 08:05:53 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NEMxz-0001bt-Vk for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 08:04:00 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NEMxu-0001Zu-KQ for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 08:03:58 -0500 Original-Received: from [199.232.76.173] (port=57626 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NEMxu-0001Zh-BG for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 08:03:54 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:34320) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NEMxt-0000F9-AW for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 08:03:53 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1NEMxs-0006qe-1P for help-gnu-emacs@gnu.org; Sat, 28 Nov 2009 14:03:52 +0100 Original-Received: from 213.211.85-79.rev.gaoland.net ([79.85.211.213]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 28 Nov 2009 14:03:52 +0100 Original-Received: from thierry.volpiatto by 213.211.85-79.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 28 Nov 2009 14:03:52 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 93 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 213.211.85-79.rev.gaoland.net Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEUHBARgJRFPS0WbMBTC TSG/uJs0yyVHAAAACXBIWXMAAAsSAAALEgHS3X78AAAACXZwQWcAAAAwAAAAMADO7oxXAAABpUlE QVQ4y3VTQXKDMAyUnD7AwvQOhtxj5N4LFh9ow/+/UtlpM0BczWSS0Wola7UBeEb3+3kJ/5p9ZLz3 UI0n0J0Y4K/lh1nG24FhlJOR2LdSKtpV5gfi/Zd+NdaJBbB4D5N0JnfUIVp6obZURkJwS2a8b9uX AkgxA5gCEcknAH1s2z0DPooWmjGKcJR+HNZt+9bm0GtGRycRuZGs98Ffr02vABWGopIAhmXmxnQN BwBXZjgFLHRoqbfeYxCLWqsjLyKhbEHW+A5nEs699Q2O80ALrgHTmUTy6P0MnKyKQpKHpoNWokxs F0D5VegvWmEozyE6nuMiS98mWzlUQ9bW8qYfqOaFtzWlYCqGeIs6HEyl08jkrxUG9MF5ipXpOOpd ZMoXPPVSLWJiiwNNB+eRSyxJZmQKcacikgucnCRiHuJOLmyYJRDPwOqAvY4pA+Wy+VS8G26BAsdb Ph2Hw7ORy/H0IOG0TnaM8Cp0XrFYyU0v2z8AqkifPVbLZ0qo/gsRg60C7p+8Ov9jrUIxFde+jnAq X42hyp/c+ZcnVyUYBarrqZt3+R8450png3cWKgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAwOC0wNS0z MVQyMjoxNDoyMiswMjowMK3VBDcAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMDctMTAtMjhUMTc6MDg6 NDgrMDE6MDDLdIcLAAAAEXRFWHRqcGVnOmNvbG9yc3BhY2UAMix1VZ8AAAAgdEVYdGpwZWc6c2Ft cGxpbmctZmFjdG9yADJ4MiwxeDEsMXgxSfqmtAAAAABJRU5ErkJggg== User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:WhJ4MW7YjSJmoVAD73M2CMGaErE= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:70211 Archived-At: pjb@informatimago.com (Pascal J. Bourguignon) writes: > 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. A little note about #., it have emacs equivalent `eval-when-compile': ,----[ That is the CL version ] | -- Special Form: eval-when-compile forms... | The FORMS are evaluated at compile-time; at execution time, this | form acts like a quoted constant of the resulting value. Used at | top-level, `eval-when-compile' is just like `eval-when (compile | eval)'. In other contexts, `eval-when-compile' allows code to be | evaluated once at compile-time for efficiency or other reasons. | | This form is similar to the `#.' syntax of true Common Lisp. `---- I don't know the #- and #+ macros, what are they for? > >>> 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. -- A + Thierry Volpiatto Location: Saint-Cyr-Sur-Mer - France