From: Zack Weinberg <zack@codesourcery.com>
Cc: emacs-devel@gnu.org
Subject: Re: byte-opt.el addition - optimize list of compile-time constants
Date: Wed, 08 Dec 2004 17:20:06 -0800 [thread overview]
Message-ID: <874qiwqncp.fsf@codesourcery.com> (raw)
In-Reply-To: <878y88s6po.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 08 Dec 2004 18:40:42 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> 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
next prev parent reply other threads:[~2004-12-09 1:20 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-08 9:21 byte-opt.el addition - optimize list of compile-time constants Zack Weinberg
2004-12-08 16:56 ` Stefan Monnier
2004-12-08 18:59 ` Zack Weinberg
2004-12-08 19:27 ` Stefan Monnier
2004-12-08 19:45 ` Zack Weinberg
2004-12-08 19:56 ` Stefan Monnier
2004-12-08 20:14 ` Nick Roberts
2004-12-08 22:47 ` Zack Weinberg
2004-12-08 23:40 ` Stefan Monnier
2004-12-09 1:20 ` Zack Weinberg [this message]
2004-12-09 2:11 ` Stefan Monnier
2004-12-09 2:33 ` Zack Weinberg
2004-12-09 2:46 ` Miles Bader
2004-12-09 3:08 ` Zack Weinberg
2004-12-09 3:28 ` Miles Bader
2004-12-09 3:48 ` Zack Weinberg
2004-12-09 4:04 ` Miles Bader
2004-12-09 4:41 ` Zack Weinberg
2004-12-09 4:52 ` Stefan Monnier
2004-12-09 5:33 ` Zack Weinberg
2004-12-09 5:39 ` Miles Bader
2004-12-09 6:49 ` Zack Weinberg
2004-12-09 15:22 ` Thien-Thi Nguyen
2004-12-10 5:50 ` Richard Stallman
2004-12-09 9:22 ` David Kastrup
2004-12-09 4:54 ` Miles Bader
2004-12-09 9:20 ` David Kastrup
2004-12-09 4:35 ` Stefan Monnier
2004-12-09 4:55 ` Zack Weinberg
2004-12-09 5:13 ` Stefan Monnier
2004-12-09 9:10 ` David Kastrup
2004-12-08 19:33 ` Paul Pogonyshev
2004-12-09 10:34 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874qiwqncp.fsf@codesourcery.com \
--to=zack@codesourcery.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.