From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Zack Weinberg Newsgroups: gmane.emacs.devel Subject: Re: byte-opt.el addition - optimize list of compile-time constants Date: Wed, 08 Dec 2004 17:20:06 -0800 Message-ID: <874qiwqncp.fsf@codesourcery.com> References: <87u0qxgn65.fsf@codesourcery.com> <878y88hazn.fsf@codesourcery.com> <87llc8tnjr.fsf@codesourcery.com> <878y88s6po.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1102555265 13917 80.91.229.6 (9 Dec 2004 01:21:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2004 01:21:05 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 09 02:20:58 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CcCzK-0006sA-00 for ; Thu, 09 Dec 2004 02:20:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CcD9B-00029W-Lt for ged-emacs-devel@m.gmane.org; Wed, 08 Dec 2004 20:31:09 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CcD8q-00028z-9F for emacs-devel@gnu.org; Wed, 08 Dec 2004 20:30:48 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CcD8p-00028Z-CQ for emacs-devel@gnu.org; Wed, 08 Dec 2004 20:30:47 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CcD8p-00028V-7m for emacs-devel@gnu.org; Wed, 08 Dec 2004 20:30:47 -0500 Original-Received: from [65.74.133.9] (helo=mail.codesourcery.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CcCyW-0007AX-E6 for emacs-devel@gnu.org; Wed, 08 Dec 2004 20:20:08 -0500 Original-Received: (qmail 1721 invoked from network); 9 Dec 2004 01:20:07 -0000 Original-Received: from localhost (HELO taltos.codesourcery.com) (zack@127.0.0.1) by mail.codesourcery.com with SMTP; 9 Dec 2004 01:20:07 -0000 Original-Received: by taltos.codesourcery.com (sSMTP sendmail emulation); Wed, 8 Dec 2004 17:20:06 -0800 Original-To: Stefan Monnier In-Reply-To: <878y88s6po.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 08 Dec 2004 18:40:42 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.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: main.gmane.org gmane.emacs.devel:30902 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30902 Stefan Monnier writes: >> (disassemble >> (lambda nil >> `(:a 1 :b 2 >> :c ,#'(lambda nil (when (eq (following-char) ?\n) (forward-char 1)))))) > [...] >> second place, byte-optimize-pure-func is called, but the optimization >> fails because a (function ...) form appears inside the arguments to >> list, which does not count as byte-compile-constp. This is the other > > Hmm... we should probably update byte-compile-constp to accept > (function ...) just like it accepts (quote ...). Yes, that sounds like a good move. >> problem I mentioned earlier - at the point at which the >> 'byte-optimizer function for list is called, the inner function has >> not yet been compiled, contrary to the general principle that the >> byte optimizer operates depth-first. > > The "byte-optimizer" has two phases: one done before > byte-compilation and one after. The byte-optimize-pure-func is done > before. Right. I was referring to the source optimizer. Whatever the consequence, this means the best the source optimizer can do is convert my `(...) form to a '(...) form, and the inner lambda won't get compiled. I suppose I'm trying to fix the bug in the wrong place. Really, what I want is for the byte compiler to look inside complicated '(...) forms for embedded lambda expressions, and compile them. I think it's byte-compile-quote that would be responsible for doing that? > As for your particular problem, there's an easier solution: > > (defun foo-aux nil (when (eq (following-char) ?\n) (forward-char 1)) > ... > (lambda nil > '(:a 1 :b 2 :c foo-aux)) This is what I've done for the time being, but I consider it somewhat infelicitous, which is why i'm flailing around trying to improve the byte compiler. zw