On Sunday, 22 September 2013 at 00:33:32 UTC, Walter Bright wrote:
On 9/21/2013 5:11 PM, Sean Kelly wrote:
Tracking the column number is certainly doable, but it comes
at a cost of
memory consumption and some compile speed, since it has to be
tracked in
every token. I used to do it in the Digital Mars C compiler,
but it was of
only marginal utility and I dropped it.
Can't you just hold a pointer to the beginning of the line and
subtract to
find the column? I agree that it's generally of marginal
utility though.
Holding the pointer has a cost of memory consumption and
compile speed :-) as well as having to have the source file
buffer stay around throughout the compile (to compute column
number you need the source in order to account for tabs &
Unicode).
Of course, we can cheat and use a byte to store the column
number, as after all, nobody has more than 256 columns.
Then you get a bug report where someone does. So raise it to an
unsigned short, then, sigh, you get another bug report where
someone's entire source file is on one line, and on it goes.
I'll go for a byte, and a well written ">256" in the message when
necessary... a very good compromise I'll tell!
/P