Subject: Re: bug#67455: (Record source position, etc., in doc strings, and use this in *Help* and backtraces.)

From: Alan Mackenzie <[email-masked]>
Date: Wed, 5 Jun 2024 15:01:57 +0000

Hello, Stefan.

On Mon, Jun 03, 2024 at 00:52:07 -0400, Stefan Monnier wrote:
> > The solution now seems obvious: In loadup.el, we should load
> > backquote.el before byte-run.el, and rewrite all our hand expanded
> > backquotes in byte-run.el (including in byte-run--posify-defining-form)
> > as actual backquote forms.

> > backquote.el doesn't actually need anything in byte-run.el bar the macro
> > defun itself.  It would be a simple job to replace each (defun
> > backquote-foo ...) in the file with (defalias 'backquote-foo #'(lambda
> > ....)).

> Well, it uses both `defun` and `defmacro`.

Yes, my mistake.  But that doesn't change the thrust of my last post.

> But rather than hand-expand them, we might be able to get the same
> result by prepending some minimal definitions of those two, as in:

>     (if (fboundp 'defun) nil
>       ;; This file is loaded before `byte-run.el' so when loading the .el
>       ;; file, defun/defmacro may not be defined yet, so we provide
>       ;; some minimalist fallback replacement.
>       (fset 'defmacro
>             (cons 'macro
>                   #'(lambda (name args &rest body)
>                       (list 'defalias (list 'quote name)
>                             (list 'cons ''macro
>                                   (list 'function
>                                         (cons 'lambda (cons args body))))))))
>       (defmacro defun (name args &rest body)
>         (list 'defalias (list 'quote name)
>               (list 'function (cons 'lambda (cons args body))))))

> These would be used only at the beginning of the bootstrap and thus
> shouldn't affect the final `src/emacs`.

I'm not sure whether or not it's worth constructing these  temporary
macros defmacro and defun - We've only got 2 defmacros and 4 defuns for
them to process, after all.

But I'm glad you seem to agree with the idea as a way of getting rid of
the extensive hand expanded backquote forms in byte-run.el.

By the way, I'm still working on the feature/positioned-lambda branch
after finding a bug there.  I'll get around to answering your reply to
my earlier post soon, hopefully.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).