all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Dave Goel <deego3@gmail.com>
Cc: 66940@debbugs.gnu.org
Subject: bug#66940: Dynamic scoping is all weird now?
Date: Sun, 05 Nov 2023 08:25:45 +0100	[thread overview]
Message-ID: <m2fs1kpsp2.fsf@Pro.fritz.box> (raw)
In-Reply-To: <CAOCW0DjkJwK47uM_nmYE5VqFGYwm8c19nqpnRbH+i15XMxRvnw@mail.gmail.com> (Dave Goel's message of "Sun, 5 Nov 2023 01:58:44 -0500")

Dave Goel <deego3@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?





  reply	other threads:[~2023-11-05  7:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-05  4:06 bug#66940: Dynamic scoping is all weird now? Dave Goel
2023-11-05  4:09 ` Dave Goel
2023-11-05  6:04   ` Gerd Möllmann
2023-11-05  6:58     ` Dave Goel
2023-11-05  7:25       ` Gerd Möllmann [this message]
2023-11-05  8:12         ` Dave Goel
2023-11-05  8:39           ` Gerd Möllmann
2023-11-05 19:07             ` Dave Goel
2023-11-05 20:21               ` Dave Goel
2023-11-06  1:52               ` Michael Heerdegen
2023-11-06  6:25                 ` Gerd Möllmann
2023-11-06 16:49                   ` Drew Adams
2023-11-06  6:57                 ` Dave Goel
2023-11-07  5:59                   ` Michael Heerdegen
2023-11-08  2:49                     ` Dave Goel
2023-11-08  3:08                       ` Michael Heerdegen
2023-11-08  3:21                         ` Dave Goel

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=m2fs1kpsp2.fsf@Pro.fritz.box \
    --to=gerd.moellmann@gmail.com \
    --cc=66940@debbugs.gnu.org \
    --cc=deego3@gmail.com \
    /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.