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

From: Alan Mackenzie <[email-masked]>
Date: Sun, 24 Mar 2024 11:21:10 +0000

Hello, Stefan.

On Tue, Mar 19, 2024 at 21:40:12 +0000, Alan Mackenzie wrote:
> On Tue, Mar 19, 2024 at 16:47:46 -0400, Stefan Monnier wrote:
> > > This might work.  What do you think?

> > I don't know what is the problem you're trying to fix, so it's hard for
> > me to have an opinion.

> > Could you clarify what is the problem when backquote is not changed
> > at all (after all, this is the problem that will also occur if the
> > programmer happened to use `cons/list` instead of backquote)?

> When Lisp gets read for interpretation, defined symbols (e.g. folliowing
> defun or cl-defgneric) get positioned, as do lambdas.  When there are ,s
> or ,@s on the arg list or the doc string of the lambda, the lambda
> currently gets posified by the new code in backquote-process.  Without
> the new code, the "complicated" lambdas retain their positions, which
> cause errors in pdump, which doesn't (and shouldn't) handle SWPs.

I was possibly too dogmatic about this.  I've actually amended pdumper.c
to handle SWPs, and this appears to be working well.  The SWPs from
"complicated" lambdas get recorded in the dumped image, and later used in
ME2.  I've reverted my changes to backquote.el.  :-)

> You're right about my sketched approach not working if the programmer
> uses cons/list instead of `, ,, and ,@.  (Thanks!)  Maybe I can somehow
> wait until (cons 'lambda (cons args body)) has been evaluated in ME2,
> before posifying the lambda.  And also take the change out of
> backquote-process.

Now coded up.

> With this idea, most of the new code would go into the (`(function ,(and
> f `(lambda ,_ . ,_))) ...) pcase arm of macrexp--expand-all, with
> possibly a new arm to catch and "neutralise" the remaining lambdas, which
> aren't functions.

It turns out there was little (?nothing) to change in
macroexp--expand-all.  The code was there already.

> >         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).