From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: byte-opt.el addition - optimize list of compile-time constants Date: Wed, 08 Dec 2004 23:35:01 -0500 Message-ID: <87brd4qeoq.fsf-monnier+emacs@gnu.org> References: <87u0qxgn65.fsf@codesourcery.com> <878y88hazn.fsf@codesourcery.com> <87llc8tnjr.fsf@codesourcery.com> <878y88s6po.fsf-monnier+emacs@gnu.org> <874qiwqncp.fsf@codesourcery.com> <87llc8qlcb.fsf-monnier+emacs@gnu.org> <87zn0op5dj.fsf@codesourcery.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1102568256 5875 80.91.229.6 (9 Dec 2004 04:57:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2004 04:57:36 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 09 05:57:31 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 1CcGMt-0001bv-00 for ; Thu, 09 Dec 2004 05:57:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CcGWl-000514-Tc for ged-emacs-devel@m.gmane.org; Thu, 09 Dec 2004 00:07:43 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CcGWU-00050T-IU for emacs-devel@gnu.org; Thu, 09 Dec 2004 00:07:26 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CcGOj-0003EF-Nv for emacs-devel@gnu.org; Wed, 08 Dec 2004 23:59:33 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CcGOg-000399-UG for emacs-devel@gnu.org; Wed, 08 Dec 2004 23:59:22 -0500 Original-Received: from [209.226.175.188] (helo=tomts25-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CcG15-000795-11 for emacs-devel@gnu.org; Wed, 08 Dec 2004 23:34:59 -0500 Original-Received: from alfajor ([67.71.27.115]) by tomts25-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20041209043457.DNVC25979.tomts25-srv.bellnexxia.net@alfajor>; Wed, 8 Dec 2004 23:34:57 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id 2F91CD7318; Wed, 8 Dec 2004 23:35:01 -0500 (EST) Original-To: Zack Weinberg In-Reply-To: <87zn0op5dj.fsf@codesourcery.com> (Zack Weinberg's message of "Wed, 08 Dec 2004 18:33:44 -0800") 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:30921 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30921 >> No. If you change byte-compile-constp to recognize `function', together >> with marking the list/cons/append primitives as pure, it should work. > How can it? The best that the source optimizer can do is turn > `(... ,#'(lambda ...) ...) into '(... #'(lambda ...) ...). This > happens *before* anything goes looking for nested functions to > compile. And I already know that if I write '(... #'(lambda ...) ...), > the function does not get compiled. Hmm... you're right. Tho it can call the byte-compiler, but that's not quite as simple as I made it out to be. >>> 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? >> >> That's dangerous because there can be a (lambda ...) form without >> it actually being meant to be byte-compiled. > which is what (function ...) is for, right? I am quite confused by > what the manual says about function vs. bare lambda expressions. No. `function' is s special form, like `quote' and `while'. But we're talking about sub-elements inside a quoted expression, i.e. random data which we have no clue whether it'll ever be used as code or not. In such a context, neither `quote', nor `while' have any special meaning: they're only symbols. > More reading, less everything-in-one-place-ness. Basically the same > thing that's infelicitous about writing a separate defun for a simple > mapcar callback that will only be used in one place. By the way: getting back to your original example: (when (require 'mmm-auto nil t) (mmm-add-classes '((md-embedded-c :submode c-mode :front "^{" :back "^}" :include-front t :include-back t ;; If the 'back' } is on a line by itself, include the carriage ;; return too; this makes the submode background highlight look ;; less strange. :back-offset #'(lambda () (when (eq (following-char) ?\n) (forward-char 1))) ))) How often is this code executed? It doesn't smell like code you're using inside a loop, so efficiency is really completely irrelevant: the extra byte-codes and consing you get with backquotes is really a total non-issue. Stefan