GNU bug report logs - #40827
28.0.50; Macroexpansion at runtime

Previous Next

Package: emacs;

Reported by: Omar Antolín Camarena <omar <at> matem.unam.mx>

Date: Fri, 24 Apr 2020 19:11:02 UTC

Severity: normal

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 40827 in the body.
You can then email your comments to 40827 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#40827; Package emacs. (Fri, 24 Apr 2020 19:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Omar Antolín Camarena <omar <at> matem.unam.mx>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 24 Apr 2020 19:11:02 GMT) Full text and rfc822 format available.

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

From: Omar Antolín Camarena <omar <at> matem.unam.mx>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; Macroexpansion at runtime
Date: Fri, 24 Apr 2020 14:09:57 -0500
I'm not sure this is a bug, but I certainly think it's odd behavior.
Basically, incorrect use of (rx ... (eval ...) ...), which should raise
an error, can instead result in macro expansion happening at runtime
rather than at function definition time.

Starting from emacs -Q, put the following in the scratch buffer:

(defmacro macro1 (arg)
  `(list :macro1 ,arg ,(format-time-string "%s")))

(setq lexical-binding nil)

(defun fun1 (arg) (list (macro1 arg) (rx (eval arg))))

Now, if you evaluate all three forms with eval-last-sexp (C-x C-e), the
definition of fun1 correctly (IMO) raises an error.

Instead evaluate the first two with eval-sexp and the last function with
eval-defun (C-M-x). No error is raised!

Next examine the definition of fun1 and call it a couple of times:

(symbol-function 'fun1)
;; evaluates to (lambda (arg) (list (macro1 arg) (rx (eval arg))))
;; notices the macros are unexpanded

(fun1 "hey")
;; evaluated to ((:macro1 "hey" "1587754829") "hey")

(fun1 "hey")
;; now I got ((:macro1 "hey" "1587754834") "hey")
;; notice the timestamp changed!

It seems that now, most of the time both the intepreter and the
byte-compiler, whether using lexical binding or not, will expand macros
at function definition time. This trick of combining an illegal (rx ...
(eval ...) ...), with lexical binding, and with eval-defun is the only
way I've found to trigger macro expansion at runtime.

I discovered this during an interesting discussion on reddit, which you
can read here:

https://www.reddit.com/r/emacs/comments/g5bat3/weekly_tipstricketc_thread/fo362s8

In that discussion others pointed out that this does not happen in Emacs
26.3: there the recipe I gave above also results in an error being
raised.

The Emacs 28 package I installed unfortunately does not come with a
manual, so I don't know what the current version says, but the manual
for Emacs 26.3 says something seemingly incorrect most of the time.

(info "(elisp) Repeated Expansion") says:

> 14.5.5 How Many Times is the Macro Expanded?

> Occasionally problems result from the fact that a macro call is
> expanded each time it is evaluated in an interpreted function, but is
> expanded only once (during compilation) for a compiled function. If
> the macro definition has side effects, they will work differently
> depending on how many times the macro is expanded.


In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0)
 of 2020-04-13, unofficial emacs-snapshot build: http://emacs.ganneff.de/, git commit fc336a46553919206d9ac621d1ea5e9740477e18 built on runner-d40f5ff3-project-26-concurrent-1
Repository revision: b5bdd1ca1d3978fc7cfc61ee14c9945e868eff7a
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12001000
System Description: Debian GNU/Linux 10 (buster)

Recent messages:
Loading mb-depth...done
Loading minibuf-eldef...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/28.0.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/28.0.50/site-lisp:/usr/share/emacs/site-lisp
 --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/28.0.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/28.0.50/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2
 -fdebug-prefix-map=/builds/joerg/emacs/buster_amd64/emacs-snapshot-20200413+emacs-27.0.90-697-gfc336a4655=.
 -fstack-protector-strong -Wformat -Werror=format-security -Wall
 -fno-omit-frame-pointer' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
 LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS PDUMPER LCMS2
GMP

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  goto-address-prog-mode: t
  show-paren-mode: t
  electric-pair-mode: t
  beginend-global-mode: t
  beginend-prog-mode: t
  global-dot-mode: t
  dot-mode: t
  global-gobble-whitespace-mode: t
  icomplete-mode: t
  minibuffer-electric-default-mode: t
  minibuffer-depth-indicate-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox hides /usr/share/emacs/28.0.50/lisp/org/ox
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-texinfo hides /usr/share/emacs/28.0.50/lisp/org/ox-texinfo
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-publish hides /usr/share/emacs/28.0.50/lisp/org/ox-publish
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-org hides /usr/share/emacs/28.0.50/lisp/org/ox-org
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-odt hides /usr/share/emacs/28.0.50/lisp/org/ox-odt
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-md hides /usr/share/emacs/28.0.50/lisp/org/ox-md
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-man hides /usr/share/emacs/28.0.50/lisp/org/ox-man
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-latex hides /usr/share/emacs/28.0.50/lisp/org/ox-latex
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-icalendar hides /usr/share/emacs/28.0.50/lisp/org/ox-icalendar
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-html hides /usr/share/emacs/28.0.50/lisp/org/ox-html
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-beamer hides /usr/share/emacs/28.0.50/lisp/org/ox-beamer
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ox-ascii hides /usr/share/emacs/28.0.50/lisp/org/ox-ascii
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org hides /usr/share/emacs/28.0.50/lisp/org/org
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-timer hides /usr/share/emacs/28.0.50/lisp/org/org-timer
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-tempo hides /usr/share/emacs/28.0.50/lisp/org/org-tempo
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-table hides /usr/share/emacs/28.0.50/lisp/org/org-table
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-src hides /usr/share/emacs/28.0.50/lisp/org/org-src
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-protocol hides /usr/share/emacs/28.0.50/lisp/org/org-protocol
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-plot hides /usr/share/emacs/28.0.50/lisp/org/org-plot
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-pcomplete hides /usr/share/emacs/28.0.50/lisp/org/org-pcomplete
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-num hides /usr/share/emacs/28.0.50/lisp/org/org-num
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-mouse hides /usr/share/emacs/28.0.50/lisp/org/org-mouse
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-mobile hides /usr/share/emacs/28.0.50/lisp/org/org-mobile
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-macs hides /usr/share/emacs/28.0.50/lisp/org/org-macs
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-macro hides /usr/share/emacs/28.0.50/lisp/org/org-macro
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-list hides /usr/share/emacs/28.0.50/lisp/org/org-list
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-lint hides /usr/share/emacs/28.0.50/lisp/org/org-lint
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-keys hides /usr/share/emacs/28.0.50/lisp/org/org-keys
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-inlinetask hides /usr/share/emacs/28.0.50/lisp/org/org-inlinetask
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-indent hides /usr/share/emacs/28.0.50/lisp/org/org-indent
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-id hides /usr/share/emacs/28.0.50/lisp/org/org-id
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-habit hides /usr/share/emacs/28.0.50/lisp/org/org-habit
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-goto hides /usr/share/emacs/28.0.50/lisp/org/org-goto
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-footnote hides /usr/share/emacs/28.0.50/lisp/org/org-footnote
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-feed hides /usr/share/emacs/28.0.50/lisp/org/org-feed
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-faces hides /usr/share/emacs/28.0.50/lisp/org/org-faces
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-entities hides /usr/share/emacs/28.0.50/lisp/org/org-entities
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-element hides /usr/share/emacs/28.0.50/lisp/org/org-element
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-duration hides /usr/share/emacs/28.0.50/lisp/org/org-duration
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-datetree hides /usr/share/emacs/28.0.50/lisp/org/org-datetree
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-ctags hides /usr/share/emacs/28.0.50/lisp/org/org-ctags
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-crypt hides /usr/share/emacs/28.0.50/lisp/org/org-crypt
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-compat hides /usr/share/emacs/28.0.50/lisp/org/org-compat
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-colview hides /usr/share/emacs/28.0.50/lisp/org/org-colview
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-clock hides /usr/share/emacs/28.0.50/lisp/org/org-clock
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-capture hides /usr/share/emacs/28.0.50/lisp/org/org-capture
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-attach hides /usr/share/emacs/28.0.50/lisp/org/org-attach
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-attach-git hides /usr/share/emacs/28.0.50/lisp/org/org-attach-git
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-archive hides /usr/share/emacs/28.0.50/lisp/org/org-archive
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-agenda hides /usr/share/emacs/28.0.50/lisp/org/org-agenda
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol hides /usr/share/emacs/28.0.50/lisp/org/ol
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-w3m hides /usr/share/emacs/28.0.50/lisp/org/ol-w3m
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-rmail hides /usr/share/emacs/28.0.50/lisp/org/ol-rmail
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-mhe hides /usr/share/emacs/28.0.50/lisp/org/ol-mhe
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-irc hides /usr/share/emacs/28.0.50/lisp/org/ol-irc
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-info hides /usr/share/emacs/28.0.50/lisp/org/ol-info
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-gnus hides /usr/share/emacs/28.0.50/lisp/org/ol-gnus
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-eww hides /usr/share/emacs/28.0.50/lisp/org/ol-eww
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-eshell hides /usr/share/emacs/28.0.50/lisp/org/ol-eshell
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-docview hides /usr/share/emacs/28.0.50/lisp/org/ol-docview
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-bibtex hides /usr/share/emacs/28.0.50/lisp/org/ol-bibtex
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ol-bbdb hides /usr/share/emacs/28.0.50/lisp/org/ol-bbdb
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob hides /usr/share/emacs/28.0.50/lisp/org/ob
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-vala hides /usr/share/emacs/28.0.50/lisp/org/ob-vala
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-tangle hides /usr/share/emacs/28.0.50/lisp/org/ob-tangle
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-table hides /usr/share/emacs/28.0.50/lisp/org/ob-table
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-stan hides /usr/share/emacs/28.0.50/lisp/org/ob-stan
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-sqlite hides /usr/share/emacs/28.0.50/lisp/org/ob-sqlite
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-sql hides /usr/share/emacs/28.0.50/lisp/org/ob-sql
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-shen hides /usr/share/emacs/28.0.50/lisp/org/ob-shen
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-shell hides /usr/share/emacs/28.0.50/lisp/org/ob-shell
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-sed hides /usr/share/emacs/28.0.50/lisp/org/ob-sed
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-screen hides /usr/share/emacs/28.0.50/lisp/org/ob-screen
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-scheme hides /usr/share/emacs/28.0.50/lisp/org/ob-scheme
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-sass hides /usr/share/emacs/28.0.50/lisp/org/ob-sass
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-ruby hides /usr/share/emacs/28.0.50/lisp/org/ob-ruby
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-ref hides /usr/share/emacs/28.0.50/lisp/org/ob-ref
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-python hides /usr/share/emacs/28.0.50/lisp/org/ob-python
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-processing hides /usr/share/emacs/28.0.50/lisp/org/ob-processing
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-plantuml hides /usr/share/emacs/28.0.50/lisp/org/ob-plantuml
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-picolisp hides /usr/share/emacs/28.0.50/lisp/org/ob-picolisp
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-perl hides /usr/share/emacs/28.0.50/lisp/org/ob-perl
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-org hides /usr/share/emacs/28.0.50/lisp/org/ob-org
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-octave hides /usr/share/emacs/28.0.50/lisp/org/ob-octave
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-ocaml hides /usr/share/emacs/28.0.50/lisp/org/ob-ocaml
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-mscgen hides /usr/share/emacs/28.0.50/lisp/org/ob-mscgen
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-maxima hides /usr/share/emacs/28.0.50/lisp/org/ob-maxima
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-matlab hides /usr/share/emacs/28.0.50/lisp/org/ob-matlab
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-makefile hides /usr/share/emacs/28.0.50/lisp/org/ob-makefile
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-lua hides /usr/share/emacs/28.0.50/lisp/org/ob-lua
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-lob hides /usr/share/emacs/28.0.50/lisp/org/ob-lob
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-lisp hides /usr/share/emacs/28.0.50/lisp/org/ob-lisp
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-lilypond hides /usr/share/emacs/28.0.50/lisp/org/ob-lilypond
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-ledger hides /usr/share/emacs/28.0.50/lisp/org/ob-ledger
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-latex hides /usr/share/emacs/28.0.50/lisp/org/ob-latex
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-js hides /usr/share/emacs/28.0.50/lisp/org/ob-js
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-java hides /usr/share/emacs/28.0.50/lisp/org/ob-java
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-io hides /usr/share/emacs/28.0.50/lisp/org/ob-io
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-hledger hides /usr/share/emacs/28.0.50/lisp/org/ob-hledger
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-haskell hides /usr/share/emacs/28.0.50/lisp/org/ob-haskell
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-groovy hides /usr/share/emacs/28.0.50/lisp/org/ob-groovy
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-gnuplot hides /usr/share/emacs/28.0.50/lisp/org/ob-gnuplot
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-fortran hides /usr/share/emacs/28.0.50/lisp/org/ob-fortran
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-forth hides /usr/share/emacs/28.0.50/lisp/org/ob-forth
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-exp hides /usr/share/emacs/28.0.50/lisp/org/ob-exp
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-eval hides /usr/share/emacs/28.0.50/lisp/org/ob-eval
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-eshell hides /usr/share/emacs/28.0.50/lisp/org/ob-eshell
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-emacs-lisp hides /usr/share/emacs/28.0.50/lisp/org/ob-emacs-lisp
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-ebnf hides /usr/share/emacs/28.0.50/lisp/org/ob-ebnf
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-dot hides /usr/share/emacs/28.0.50/lisp/org/ob-dot
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-ditaa hides /usr/share/emacs/28.0.50/lisp/org/ob-ditaa
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-css hides /usr/share/emacs/28.0.50/lisp/org/ob-css
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-core hides /usr/share/emacs/28.0.50/lisp/org/ob-core
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-coq hides /usr/share/emacs/28.0.50/lisp/org/ob-coq
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-comint hides /usr/share/emacs/28.0.50/lisp/org/ob-comint
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-clojure hides /usr/share/emacs/28.0.50/lisp/org/ob-clojure
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-calc hides /usr/share/emacs/28.0.50/lisp/org/ob-calc
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-awk hides /usr/share/emacs/28.0.50/lisp/org/ob-awk
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-asymptote hides /usr/share/emacs/28.0.50/lisp/org/ob-asymptote
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-abc hides /usr/share/emacs/28.0.50/lisp/org/ob-abc
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-R hides /usr/share/emacs/28.0.50/lisp/org/ob-R
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-J hides /usr/share/emacs/28.0.50/lisp/org/ob-J
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/ob-C hides /usr/share/emacs/28.0.50/lisp/org/ob-C
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-version hides /usr/share/emacs/28.0.50/lisp/org/org-version
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-loaddefs hides /usr/share/emacs/28.0.50/lisp/org/org-loaddefs
/home/omarantolin/.emacs.d/elpa/org-plus-contrib-20200420/org-install hides /usr/share/emacs/28.0.50/lisp/org/org-install

Features:
(shadow sort bbdb-message vc-git diff-mode mailalias bbdb-mua bbdb-com
crm bbdb bbdb-site timezone mail-extr emacsbug message rmc puny dired
dired-loaddefs format-spec rfc822 mml mml-sec epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils rx
orderless goto-addr thingatpt email-config pdf-loader paren elec-pair
ace-link avy ring beginend dot-mode eval-region-advice gobble-whitespace
icomplete minibuf-eldef mb-depth completing-history block-undo
modus-vivendi-theme modus-operandi-theme cus-edit cus-start cus-load
wid-edit diminish cl-extra help-mode use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core finder-inf edmacro kmacro tex-site
slime-autoloads info package easymenu browse-url url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
x multi-tty make-network-process emacs)

Memory information:
((conses 16 302715 12983)
 (symbols 48 19818 1)
 (strings 32 86684 5262)
 (string-bytes 1 2363915)
 (vectors 16 24403)
 (vector-slots 8 327959 11678)
 (floats 8 93 145)
 (intervals 56 302 0)
 (buffers 992 11))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40827; Package emacs. (Sat, 25 Apr 2020 14:50:01 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Omar Antolín Camarena <omar <at> matem.unam.mx>
Cc: 40827 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#40827: 28.0.50; Macroexpansion at runtime
Date: Sat, 25 Apr 2020 10:49:03 -0400
Omar Antolín Camarena <omar <at> matem.unam.mx> writes:

> It seems that now, most of the time both the intepreter and the
> byte-compiler, whether using lexical binding or not, will expand macros
> at function definition time. This trick of combining an illegal (rx ...
> (eval ...) ...), with lexical binding, and with eval-defun is the only
> way I've found to trigger macro expansion at runtime.
[...]
> I discovered this during an interesting discussion on reddit, which you
> can read here:
>
> https://www.reddit.com/r/emacs/comments/g5bat3/weekly_tipstricketc_thread/fo362s8
[...]
> (info "(elisp) Repeated Expansion") says:
>
>> 14.5.5 How Many Times is the Macro Expanded?
>
>> Occasionally problems result from the fact that a macro call is
>> expanded each time it is evaluated in an interpreted function, but is
>> expanded only once (during compilation) for a compiled function. If
>> the macro definition has side effects, they will work differently
>> depending on how many times the macro is expanded.

Also further down:

       [...] But in interpreted execution, the macro is expanded each
    time the macro call runs
    [...]
    If `initialize' is interpreted, a new list `(nil)' is constructed each
    time `initialize' is called.

(elisp "(elisp) Expansion") does mention that uncompiled macro calls
(usually) also get expanded just once:

       Note that Emacs tries to expand macros when loading an uncompiled
    Lisp file.  This is not always possible, but if it is, it speeds up
    subsequent execution.  *Note How Programs Do Loading::.

Ccing Stefan M, since you made the eager macroexpansion changes as far
as I recall.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40827; Package emacs. (Sat, 25 Apr 2020 20:06:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Omar Antolín Camarena <omar <at> matem.unam.mx>,
 40827 <at> debbugs.gnu.org
Subject: Re: bug#40827: 28.0.50; Macroexpansion at runtime
Date: Sat, 25 Apr 2020 16:04:49 -0400
>>> Occasionally problems result from the fact that a macro call is
>>> expanded each time it is evaluated in an interpreted function, but is
>>> expanded only once (during compilation) for a compiled function. If
>>> the macro definition has side effects, they will work differently
>>> depending on how many times the macro is expanded.

We could be more nuanced, indeed, since the "expanded once" can also
happen for interpreted code (and the "expand many times" can also happen
in code that's in a compiled file, if that code happened to be "hidden"
from the compiler, such as hidden within a `quote`).

But the basic idea remains the same: macro expansion may happen only
once as part of the preprocessing, or it may be performed anew each time
the code is run (or anything in-between, really), so the code should not
make assumptions about when macros are expanded or how many times
they're expanded.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40827; Package emacs. (Sun, 26 Apr 2020 03:30:01 GMT) Full text and rfc822 format available.

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

From: Richard Stallman <rms <at> gnu.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: omar <at> matem.unam.mx, 40827 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#40827: 28.0.50; Macroexpansion at runtime
Date: Sat, 25 Apr 2020 23:28:57 -0400
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

      >    [...] But in interpreted execution, the macro is expanded each
      > time the macro call runs
      > [...]
      > If `initialize' is interpreted, a new list `(nil)' is constructed each
      > time `initialize' is called.

Aside from the issue you're discussing, that text has the drawback of
using the passive voice.  The passive voice tends to be less readable,
and it can obscure who or what is performing the action.  Would someone
please rewrite it to use the active voice?

Occasionally the passive voice is necessary, but please write
in the active voice whenever that works.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40827; Package emacs. (Tue, 10 Aug 2021 16:06:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Omar Antolín Camarena <omar <at> matem.unam.mx>,
 40827 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> gmail.com>
Subject: Re: bug#40827: 28.0.50; Macroexpansion at runtime
Date: Tue, 10 Aug 2021 18:05:32 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> We could be more nuanced, indeed, since the "expanded once" can also
> happen for interpreted code (and the "expand many times" can also happen
> in code that's in a compiled file, if that code happened to be "hidden"
> from the compiler, such as hidden within a `quote`).

---
  If the macro is expanded just once, in compilation, then the object is
constructed just once, during compilation.  But in interpreted
execution, the macro is expanded each time the macro call runs, and this
means a new object is constructed each time.
---

I think this is pretty clear -- it's guarded by "if", but it doesn't
claim that compilation will always expand the macro.  So I think this
should be sufficient, and I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 40827 <at> debbugs.gnu.org and Omar Antolín Camarena <omar <at> matem.unam.mx> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 10 Aug 2021 16:06:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 08 Sep 2021 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 231 days ago.

Previous Next


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