[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting the correct line/column numbers on byte compilation error/wa
Re: Getting the correct line/column numbers on byte compilation error/warning messages
Mon, 17 Jul 2017 16:27:43 -0400
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
>> Stefan "who'd actually prefer a «real» solution rather than
>> another hack, but beggars can't be choosers"
> I've been thinking about this for nearly a year, and I can't conceive of
> a "real" solution which doesn't involve redesigning the byte compiler
> from scratch (or even one which does).
AFAIK redesign is not needed (in the sense that the code structure
doesn't need to be changed), but a lot of code would need to be
> Lisp source code doesn't seem to lend itself to keeping track of
> source positions as the forms are manipulated, taken apart, and put
> together again.
All compilers for all languages do that "take-apart-and-put-together"
over and over again. The only difference is the Lisp macros which are
defined to operate on a form of the code which doesn't include
> Can you conceive of some better scheme by which accurate line/column
> numbers can be output by error messages, and which doesn't involve
> rewriting the byte compiler?
The «real» solution, AFAIC, is to use a representation of the code where
position-info is added to each node:
- provide a new `read` function which provides something similar to
`edebug-read` (and then change Edebug to use that function).
- change macroexp to accept and return such a representation.
- change byte-opt to accept and return such a representation.
- change cconv to accept and return such a representation.
- change bytecomp.el to accept representation.
The changes to macroexp, byte-opt, cconv, and bytecomp aren't
complicated and will be fairly repetitive, but they'll touch most of
> What I do anticipate about my hack is, assuming I ever get it working,
> it will produce the correct source code positions all the time, not just
> most of the time.
It might work well in practice, yes. Tho using setc[ad]r like you
suggest is risky since macros can return code which is a DAG rather than
a tree (it's fairly unusual but not unheard of), so if you setc[ad]r on
one side it might lead to nasty surprises on the other.