From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#13813: 24.3.50; eval-and-compile in macro inhibits let-binding of variable Date: Mon, 25 Feb 2013 15:53:21 -0500 Message-ID: References: <87d2vo5nzy.fsf@engster.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361825668 12964 80.91.229.3 (25 Feb 2013 20:54:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Feb 2013 20:54:28 +0000 (UTC) Cc: 13813@debbugs.gnu.org To: David Engster Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 25 21:54:51 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UA54Q-0005s6-Rh for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Feb 2013 21:54:46 +0100 Original-Received: from localhost ([::1]:47376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UA546-0003vY-5p for geb-bug-gnu-emacs@m.gmane.org; Mon, 25 Feb 2013 15:54:26 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UA543-0003tp-0e for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 15:54:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UA541-0007fl-BW for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 15:54:22 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UA541-0007fh-7v for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 15:54:21 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UA55d-0003FA-Oz for bug-gnu-emacs@gnu.org; Mon, 25 Feb 2013 15:56:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Feb 2013 20:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13813 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13813-submit@debbugs.gnu.org id=B13813.136182570512402 (code B ref 13813); Mon, 25 Feb 2013 20:56:01 +0000 Original-Received: (at 13813) by debbugs.gnu.org; 25 Feb 2013 20:55:05 +0000 Original-Received: from localhost ([127.0.0.1]:50060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UA54j-0003Dz-Gx for submit@debbugs.gnu.org; Mon, 25 Feb 2013 15:55:05 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:32289) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UA54h-0003Dr-J1 for 13813@debbugs.gnu.org; Mon, 25 Feb 2013 15:55:04 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFHO+KLv/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCwsOJhIUGA0kLodwBsEtkQoDiGGcGYFegxU X-IPAS-Result: Av8EABK/CFHO+KLv/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCwsOJhIUGA0kLodwBsEtkQoDiGGcGYFegxU X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="2432090" Original-Received: from 206-248-162-239.dsl.teksavvy.com (HELO pastel.home) ([206.248.162.239]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 25 Feb 2013 15:53:20 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 9DB196C0A9; Mon, 25 Feb 2013 15:53:21 -0500 (EST) In-Reply-To: <87d2vo5nzy.fsf@engster.org> (David Engster's message of "Mon, 25 Feb 2013 17:58:41 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:71800 Archived-At: > Recipe: > * Create a file test.el with the following contents: > (defvar myflag nil) > (defmacro mytestmacro () > "An eval-and-compile test." > `(eval-and-compile (mytestfun))) > (defun mytestfun () > (when myflag > (message "foo"))) > (let ((myflag t)) > ;; Should display "foo" > (mytestmacro)) > * Now call with Emacs from trunk: > emacs --batch -l test.el > * "foo" should be displayed, but isn't. The Emacs 24.2.93 pretest > however works as expected. OK, you got me, I admit it, my recent change to eval-and-compile makes it a lie. Basically, there are now 3 different times: - compile-time - load-time (aka "eager-macroexpansion") - eval-time Most eval-and-compile are used for definitions which are used in macros (hence needed for both compile-time and load-time). For this reason, I changed recently eval-and-compile to be (in effect) eval-during-load-and-compile. I could turn it into a eval-during-eval-load-and-compile, but then your above test would run `mytestfun' twice (once with myflag=nil and then once with myflag=t) which I don't think would please everyone either. > * Note the following: > - It works if you just 'setq' the 'myflag' variable But not if you (progn (setq myflag t) (mytestmacro)). The issue is whether the setq takes place in a separate top-level expression, in which case it's run before eager-macroexpansion of the expression that does the (mytestmacro). > - The same problem occurs with `eval-when-compile', but everything > works with `progn'. Yes, it's basically the same problem. > And yes, Stefan, this bug turned up in the EIEIO test suite. :-) Could you give some details, so we can better assess the best solution? BTW, I think eval-and-compile should only be used to wrap definitions. Anything else is asking for trouble. Stefan