From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Strange behavior of macro Date: Tue, 30 May 2006 11:34:39 +0200 Message-ID: <85u07797ps.fsf@lola.goethe.zz> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1148987165 19497 80.91.229.2 (30 May 2006 11:06:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 30 May 2006 11:06:05 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 30 13:06:01 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fl22n-0000XH-OR for ged-emacs-devel@m.gmane.org; Tue, 30 May 2006 13:05:49 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fl22n-0004c9-6e for ged-emacs-devel@m.gmane.org; Tue, 30 May 2006 07:05:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fl22Z-0004XK-78 for emacs-devel@gnu.org; Tue, 30 May 2006 07:05:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fl22Y-0004Va-1C for emacs-devel@gnu.org; Tue, 30 May 2006 07:05:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fl22X-0004V9-RP for emacs-devel@gnu.org; Tue, 30 May 2006 07:05:33 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fl28J-0001bj-S2 for emacs-devel@gnu.org; Tue, 30 May 2006 07:11:31 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1Fl22W-0006se-VC; Tue, 30 May 2006 07:05:33 -0400 Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id A50081C142BC; Tue, 30 May 2006 11:34:39 +0200 (CEST) Original-To: "Herbert Euler" In-Reply-To: (Herbert Euler's message of "Tue, 30 May 2006 16:56:56 +0800") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:55475 Archived-At: "Herbert Euler" writes: > Is the following in Emacs a expected behavior of macro? > > (defmacro m1 (v) > (let ((len (length (eval v)))) > `(quote ,len))) > => m1 > > (m1 '(1 2 3)) > => 3 > > (setq v1 '(1 2 3)) > => (1 2 3) > > (m1 v1) > => 3 > > (setq v v1) > => (1 2 3) > > (m1 v) > => error: (wrong-type-argument sequencep v) In combination with dynamic scope, yes. m1 gets passed 'v as v, so now v is bound to 'v and (eval v) again delivers 'v. Evaluating a macro argument in the macro itself is often asking for trouble. And Elisp's scoping rules don't exactly help. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum