unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#40827: 28.0.50; Macroexpansion at runtime
@ 2020-04-24 19:09 Omar Antolín Camarena
  2020-04-25 14:49 ` Noam Postavsky
  0 siblings, 1 reply; 5+ messages in thread
From: Omar Antolín Camarena @ 2020-04-24 19:09 UTC (permalink / raw)
  To: 40827


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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#40827: 28.0.50; Macroexpansion at runtime
  2020-04-24 19:09 bug#40827: 28.0.50; Macroexpansion at runtime Omar Antolín Camarena
@ 2020-04-25 14:49 ` Noam Postavsky
  2020-04-25 20:04   ` Stefan Monnier
  2020-04-26  3:28   ` Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Noam Postavsky @ 2020-04-25 14:49 UTC (permalink / raw)
  To: Omar Antolín Camarena; +Cc: 40827, Stefan Monnier

Omar Antolín Camarena <omar@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#40827: 28.0.50; Macroexpansion at runtime
  2020-04-25 14:49 ` Noam Postavsky
@ 2020-04-25 20:04   ` Stefan Monnier
  2021-08-10 16:05     ` Lars Ingebrigtsen
  2020-04-26  3:28   ` Richard Stallman
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2020-04-25 20:04 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Omar Antolín Camarena, 40827

>>> 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






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#40827: 28.0.50; Macroexpansion at runtime
  2020-04-25 14:49 ` Noam Postavsky
  2020-04-25 20:04   ` Stefan Monnier
@ 2020-04-26  3:28   ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2020-04-26  3:28 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: omar, 40827, monnier

[[[ 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)







^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#40827: 28.0.50; Macroexpansion at runtime
  2020-04-25 20:04   ` Stefan Monnier
@ 2021-08-10 16:05     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-10 16:05 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Omar Antolín Camarena, 40827, Noam Postavsky

Stefan Monnier <monnier@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-10 16:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-24 19:09 bug#40827: 28.0.50; Macroexpansion at runtime Omar Antolín Camarena
2020-04-25 14:49 ` Noam Postavsky
2020-04-25 20:04   ` Stefan Monnier
2021-08-10 16:05     ` Lars Ingebrigtsen
2020-04-26  3:28   ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).