From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jeff Clough Newsgroups: gmane.emacs.help Subject: Re: Is it possible for a macro to expand to nothing? Date: Wed, 25 Nov 2009 09:13:16 -0500 (EST) Message-ID: <20091125.091316.197573325.jeff@chaosphere.com> References: <87ljhwb2dx.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 1259159001 8070 80.91.229.12 (25 Nov 2009 14:23:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Nov 2009 14:23:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 25 15:23:14 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 1NDIlt-00070l-3x for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Nov 2009 15:23:05 +0100 Original-Received: from localhost ([127.0.0.1]:58271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDIls-0005ow-Ko for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Nov 2009 09:23:04 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDIbv-00006n-Kv for help-gnu-emacs@gnu.org; Wed, 25 Nov 2009 09:12:47 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDIbs-00006E-P5 for help-gnu-emacs@gnu.org; Wed, 25 Nov 2009 09:12:46 -0500 Original-Received: from [199.232.76.173] (port=43232 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDIbs-00006B-Ir for help-gnu-emacs@gnu.org; Wed, 25 Nov 2009 09:12:44 -0500 Original-Received: from hrndva-omtalb.mail.rr.com ([71.74.56.123]:45803) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDIbs-0000bD-LN for help-gnu-emacs@gnu.org; Wed, 25 Nov 2009 09:12:44 -0500 Original-Received: from localhost ([74.70.71.134]) by hrndva-omta04.mail.rr.com with ESMTP id <20091125141243002.FVUZ18441@hrndva-omta04.mail.rr.com> for ; Wed, 25 Nov 2009 14:12:43 +0000 X-Mailer: Mew version 6.3rc1 on Emacs 23.1 / Mule 6.0 (HANACHIRUSATO) In-Reply-To: X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (1203?) 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:70122 Archived-At: From: Alan Mackenzie Date: Tue, 24 Nov 2009 16:39:20 +0000 (UTC) >> It comes directly from the definition of defmacro, > >> defmacro is a special form in `src/eval.c'. >> (defmacro name arglist [docstring] [decl] body...) > >> Define name as a macro. >> The actual definition looks like >> (macro lambda arglist [docstring] [decl] body...). >> When the macro is called, as in (name ARGS...), >> the function (lambda arglist body...) is applied to >> the list ARGS... as it appears in the expression, >> and the result should be a form to be evaluated instead of the original. > > Oh, come on! That last sentence is a tutorial, motivating one, expressed > in the slightly loose, colloquial language of the hacker. "a form to be > evaluated" is here shorthand for something like "some sort of atom or > list structure which fits into the slot where the invocation is housed" This is incorrect. The term "form" has a very specific definition in Lisp. It is a sexp that can be evaluated. While I'm new to Lisp, I have been knee deep in books and documents for the last couple of weeks and everything (including the GNU Emacs Lisp Manual) presents macros as a way to generate *forms*, not just sexps. If you have a macro that expands to (1 2 3), it's not going to break the world, but that macro isn't doing what every hacker is going to expect. I'd call that a style problem. If, for some reason, you absolutely have to use a macro to generate something like that above, at least have it expand to (list 1 2 3), that way the macro can still be evaluated and no one gets shafted. You get the behavior you want and the macro is still expanding to a valid form. Jeff