On Sep 21, 2013, at 5:33 PM, Walter Bright <[email protected]> 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. A single pointer per file isn't much memory and a write per line isn't much of a speed hit. Fair point about holding the file in memory except that DMD does this anyway. Mine wasn't a general comment so much as one specifically about the D front end. As for the rest, if you can see the problems with an approach before starting then don't do it that way. :-)
