emacs-devel
[Top][All Lists]
Advanced

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

Re: Thoughts on the buffer positions in the byte compiler's warning mess


From: Alan Mackenzie
Subject: Re: Thoughts on the buffer positions in the byte compiler's warning messages.
Date: Sun, 18 Sep 2016 17:38:51 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Emacs.

On Sun, Sep 18, 2016 at 03:23:03PM +0000, Alan Mackenzie wrote:
> ######################################################################### 

> I've been trying to come up with a general solution to these problems.
> What I have at the moment, which is rather vague, amounts to this:

> After the reader has produced the form to be compiled and
> read-symbol-positions-list, we combine these to produce a @dfn{shadow
> form} with the same shape as the form, but where there's a symbol in the
> form, there is a corresponding list in the shadow form, noting the
> corresponding "position" in the form, and onto which warning/error
> messages can be pushed.  These can then be output at the end of the
> compilation.

> The info in the shadow form will allow the correct node corresponding to
> one in the form to be found, thus correct line/column numbers in
> messages are assured for normal code.  Possibly a hash table will serve
> somehow to speed up searches.

> For transformed code (macro invocations, optimised forms, etc.), things
> become more difficult.  However, these transformations mostly leave most
> of the cons cells in the form unchanged, just rearranging them somewhat.
> So the "pointers" in the shadow form will continue to be associated with
> them, enabling accurate warning messages even here.

> Obviously, this mechanism would cause the byte compiler to run more
> slowly.  Whether or not this is significant or not would be down to
> experience.

> Comments?

Actually, with a bit more thought, the above is totally over the top.

What's needed is to construct a hash table whose key is a cons cell in
the form which the reader has just built, and whose value is the
position of the symbol in the car of that cons cell.  OK, something is
needed for vectors, too, and maybe one or two other things.

This hash table can easily be built from the available information (the
form and read-symbol-positions-list), and once the mechanism is seen to
be working we could get the reader to produce this hash table directly.

Then when we want to output a diagnostic, in addition to passing the
string to byte-compile-warn, we also pass a cons cell representing the
position we want output.

This should work.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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