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

From: Alan Mackenzie <[email-masked]>
Date: Sat, 1 Jun 2024 17:40:47 +0000

Hello, Stefan and Eli.

On Mon, Mar 04, 2024 at 15:38:14 +0000, Alan Mackenzie wrote:

[ .... ]

> I've just pushed a large commit to feature/positioned-lambdas, a work
> in progress commit for bug#67455, putting source position information at
> the start of doc strings.  master was merged into it just before the
> commit.

I've just pushed another large commit, which now works, for generous
values of "works".

[ .... ]

> Still missing is position information for defvars and defconsts, along
> with the same for cl-defmethods (which are complicated because the doc
> string has no fixed position).

This is now implemented.

> Also missing is the handling of Oclosures.

This is still missing.

[ .... ]

What has held me back over the last weeks was handling ambiguous
constructs - things that might be evaluated, but might not.  Things like
'(defun ...) or (lambda ...) in the middle of a constant, or things like 
(memq (car form) '(defun defsubst)) in elint.el, where defsubst is
definitely not a function being defined.

Currently, I have coped with this using heuristics.  For example that
'(defun ...) is not a function definition because of the '.  Or that
(list 'lambda (list foo bar) ....) is the expansion of a backquote form,
thus must be an evaluatable form.  This is clearly unsatisfactory.

I think a moderately radical change in approach is needed.  Something
like the following:

(i) "Ambiguous" constructs should be left with symbols with position.
(ii) We should enhance the evaluator to handle these symbols with
  position.
(iii) For the sake of run time speed, typical SWPs will be posified as
  they are at the moment, the details getting written into their doc
  strings.
(iv) We'll need a read syntax for symbols with position, and they will
  get written to .elc files with this syntax.
(v) SWPs may need enhancing with a new element representing the buffer
  the symbol occurred in.  Or, we could have an alist (or hash table)
  associating the SWPs with their buffers.  Such currently exists for
  lambdas.

.... or something like that.

What do you think?

-- 
Alan Mackenzie (Nuremberg, Germany).