GNU bug report logs - #66940
Dynamic scoping is all weird now?

Previous Next

Package: emacs;

Reported by: Dave Goel <deego3 <at> gmail.com>

Date: Sun, 5 Nov 2023 04:08:02 UTC

Severity: normal

Tags: notabug

Done: Michael Heerdegen <michael_heerdegen <at> web.de>

Bug is archived. No further changes may be made.

Full log


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

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Dave Goel <deego3 <at> gmail.com>
Cc: 66940 <at> debbugs.gnu.org
Subject: Re: bug#66940: Dynamic scoping is all weird now?
Date: Sun, 05 Nov 2023 08:25:45 +0100
Dave Goel <deego3 <at> gmail.com> writes:

> (defmacro mac()
>   `(progn
>      (message "%S" ,ii)
>      (sit-for 0.1)))
>
> So, the original macro had a brain-fart basically amounted to returning nil
> unconditionally.
> In that case, why were we getting that strange error?

Don't know exactly what the "strage error" refers to, but maybe a (pp
(macrexpand-all ...)) helps? In this case, the result is

"(progn
  (setq lexical-binding nil)
  (let ((upper-bound 10) (counter 0))
    (while (< counter upper-bound)
      (let ((ii counter))
	(defalias 'mac
	  (cons 'macro
		#'(lambda nil (list 'message \"%S\" ii) (sit-for 0.1))))
	(let ((old_ii ii)) (setq ii 33) (mac) (setq ii old_ii)))
      (setq counter (1+ counter)))))

One things that gets kind of more obvious is that defmacro is something
"global" in the sense that it sets mac's symbol function. You could
moved the defmacro out of the progn somewhere else.

Does that help?




This bug report was last modified 1 year and 199 days ago.

Previous Next


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