[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: byte-opt.el addition - optimize list of compile-time constants

From: Stefan Monnier
Subject: Re: byte-opt.el addition - optimize list of compile-time constants
Date: Wed, 08 Dec 2004 23:35:01 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

>> 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)
      :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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]