GNU bug report logs - #18821
25.0.50; Let pp-macroexpand-expression expand only once

Previous Next

Package: emacs;

Reported by: michael_heerdegen <at> web.de

Date: Fri, 24 Oct 2014 23:15:02 UTC

Severity: wishlist

Found in version 25.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 18821 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 18821 <at> debbugs.gnu.org
Subject: Re: bug#18821: 25.0.50; Let pp-macroexpand-expression expand only once
Date: Tue, 28 Oct 2014 13:00:09 -0400
>     (defun macroexpand1 (expr)
>       (apply (cdr (symbol-function (car expr))) (cdr expr)))

Daniel Colascione already submitted a patch that provides
a macroexpand1.  And if that's not sufficient I also wrote my own.
The only reason I haven't installed it is because it would make a lot of
sense to reimplement `macroexpand' (in Elisp) on top of `macroexpand1',
but when I tried that, byte-compilation slowed down by about 5%, which
seemed excessive (especially since it reflects an even larger slowdown
of macroexpansion itself, tho I haven't measured that in more detail).


        Stefan


(defun macroexp-expand-1 (form environment)
  "Perform (at most) one step of macroexpansion."
  (cond
   ((consp form)
    (let* ((head (car form))
           (env-expander (assq head environment)))
      (if env-expander
          (if (cdr env-expander)
              (apply (cdr env-expander) (cdr form))
            form)
        (if (not (and (symbolp head) (fboundp head)))
            form
          (let ((def (autoload-do-load (symbol-function head) head 'macro)))
            (cond
             ;; Follow alias, but only for macros, otherwise we may end up
             ;; skipping an important compiler-macro (e.g. cl--block-wrapper).
             ((and (symbolp def) (macrop def)) (cons def (cdr form)))
             ((not (consp def)) form)
             (t
              (if (eq 'macro (car def))
                  (apply (cdr def) (cdr form))
                form))))))))
   (t form)))




This bug report was last modified 10 years and 203 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.