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

From: Alan Mackenzie <[email-masked]>
Date: Tue, 19 Mar 2024 21:40:12 +0000

Hello, Stefan.

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.

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.

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.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).