bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#3466: 23.0.94; have `d' in debugger treat macro expansion like `c' d


From: Drew Adams
Subject: bug#3466: 23.0.94; have `d' in debugger treat macro expansion like `c' does
Date: Thu, 20 Oct 2022 16:04:04 +0000

> > (defun foo () (dotimes (i 2) (message "foo")))
> >
> > and `M-x debug-on-entry' on foo, `M-: (foo)', just hitting `d' a lot
> > does what I'd expect -- stepping through all the code.  It does not seem
> > to step the through the macro expansion itself.  (At least not in Emacs
> > 27.1 or 28.)
> 
> I also don't understand what Drew writes.  Especially why c would do
> something that a repeated d would not get you to, sooner or later.

Nothing in the enhancement request suggested that `c'
does anything that repeated `d' won't do.  The point
was to (optionally) have some particular repetitions
of `d' be handled like `c': skip over the need to
repeat `d' for those cases.  Which cases: macro
expansions.

> Drew, did you bind c to something else?  Or had your code been loaded
> under some special conditions?  Normally what the debugger steps through
> doesn't contain macro calls - even for uncompiled code and even for the
> dynamically binding dialect.  So unless you were debugging quoted
> lambdas, I'm ... confused.

I appreciate the attention to the bug report, but it
was reported 14 years ago.  Well, let's see.

I think the point of the enhancement request was to
optionally be able to have `d' in the debugger act
like `c' when a macro is encountered - only to expand
the macro, not to evaluate the result of expansion.
More precisely, act like `c' when the macro expression
to be expanded would be shown.

`dolist' is a macro.  In Emacs 23 (which is when the
request was filed), you see this, if you use
(debug-on-entry 'foo), for this code:

(setq xs '((1 2) 42 (a b c)))
(defun foo ()
  (dolist (x xs)
    (message "%S" x)))

Debugger entered--entering a function:
* append(((message "%S" x)) ((setq --dolist-tail-- (cdr --dolist-tail--))))
* #[(spec &rest body) ...
* (dolist (x xs) (message "%S" x))
* foo()
  eval((foo))
  eval-expression((foo) nil)
  call-interactively(eval-expression)

The point was to (be able to, optionally) have `d' on
the #[(spec &rest body) ... line (not the `dolist'
line) act like `c' there - immediately giving the
result of its expansion.

Now, in more recent versions of Emacs you don't see
the (dolist...) line at all; you directly see `while'
instead:

Debugger entered--beginning evaluation of function call form:
* (while --dolist-tail-- ...
* (let ((--dolist-tail-- xs) x) (while --dolist-tail...
* (lambda nil (let ((--dolist-tail-- xs) x) (while --dolist-tail...
* apply((lambda nil (let ((--dolist-tail-- xs) x) (while --dolist-tail--...
* foo()
  eval((foo) t)
  eval-expression((foo) nil nil 127)
  funcall-interactively(eval-expression (foo) nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

That's fine.  Emacs was enhanced as requested.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]