From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: byte-compile-maybe-guarded Date: Sun, 02 Mar 2008 17:38:23 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1204497523 9516 80.91.229.12 (2 Mar 2008 22:38:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Mar 2008 22:38:43 +0000 (UTC) Cc: Dan Nicolaescu , emacs-devel@gnu.org To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 02 23:39:10 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JVwpp-0004Hi-4K for ged-emacs-devel@m.gmane.org; Sun, 02 Mar 2008 23:39:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVwpI-00060Y-AP for ged-emacs-devel@m.gmane.org; Sun, 02 Mar 2008 17:38:36 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JVwpD-0005yo-DU for emacs-devel@gnu.org; Sun, 02 Mar 2008 17:38:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JVwpB-0005xB-Sr for emacs-devel@gnu.org; Sun, 02 Mar 2008 17:38:31 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JVwpB-0005wc-GS for emacs-devel@gnu.org; Sun, 02 Mar 2008 17:38:29 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JVwp7-0003pN-I0; Sun, 02 Mar 2008 17:38:25 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAMq7ykdMCrW2/2dsb2JhbACrC4EA X-IronPort-AV: E=Sophos;i="4.25,435,1199682000"; d="scan'208";a="15465905" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 02 Mar 2008 17:38:24 -0500 Original-Received: from pastel.home ([76.10.181.182]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id IZO31424; Sun, 02 Mar 2008 17:38:24 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id DC6C78279; Sun, 2 Mar 2008 17:38:23 -0500 (EST) In-Reply-To: (Glenn Morris's message of "Sat, 01 Mar 2008 15:07:00 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. 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:91115 Archived-At: > FYI I've restored the code in byte-compile-maybe-guarded that you > commented out 2007-11-10. Without this code, a false warning is > produced in the following case: > foo.el: > (defsubst foo () > (if (featurep 'xemacs) (setq foo t))) ; foo is a free variable > (provide 'foo) > bar.el: > (require 'foo) > (foo) It seems the problem is in the (lack of) optimization of forms like ((lambda (args) body) exps) You can see it by byte-compiling (defun foo () ((lambda () (if (featurep 'xemacs) (setq foo t))))) I.e. the patch below seems to fix the problem the right way. I'm just not 100% sure it can't introduce an infinite optimization loop. Stefan --- orig/lisp/emacs-lisp/byte-opt.el +++ mod/lisp/emacs-lisp/byte-opt.el @@ -383,7 +383,9 @@ form)) ((or (byte-code-function-p fn) (eq 'lambda (car-safe fn))) - (byte-compile-unfold-lambda form)) + (byte-optimize-form + (byte-compile-unfold-lambda form) + for-effect)) ((memq fn '(let let*)) ;; recursively enter the optimizer for the bindings and body ;; of a let or let*. This for depth-firstness: forms that