3 ms·
> grapheme clusters [...] portable If only. Boundary locations are dependent on unicode version. If your terminal uses one and your compiler another—boom.
by moonchild 5y ago
> grapheme clusters [...] portable
If only. Boundary locations are dependent on unicode version. If your terminal uses one and your compiler another—boom.
* * *
In my c compiler I distinguish 'acol' and 'vcol'. The former stands for 'actual column', and the latter for 'visual column'. The actual column is a byte offset, which can be used to identify the offending location in source, while the visual column represents a physical offset in glyph-widths.
The issue given in TLA of tab widths being different can be resolved by making the compiler expand the tabs itself. This does nothing for e.g. emoji, if there is disagreement about the version of unicode in use.
Vim seems to do something similar. Given 'set ruler', if I type a tab followed by an em dash, I am told that I am in column '5-10'. 5 is 3 bytes from the em dash (in utf8) and 1 byte from the tab, plus 1. 10 is 8 glyph-widths from the tab and 1 glyph-width from the em dash, plus 1.
* * *
However, my approach to error-handling should perhaps not be taken as representative. E.G.
> But nobody looks at an error message and manually navigates to the location using the column information!
I do. And I also dislike rustc's error messages, which apparently receive universal acclaim.
- bombela 5y agoI want to know more about why you disklike rustc error messages. I always found them legible, precise and helpful at the same time.
- moonchild 5y agoThey are exceedingly verbose. The most important part of a compiler error, to me, is location information. Use of colour (and possibly other formatting) to draw the eye directly to the site of the error is valuable. Sometimes this is enough, and the issue immediately becomes obvious. Sometimes it is not. In the case where it is, and there are multiple errors, the proliferation of text obscures the display of code itself. I can scroll, sure; but the human-computer communication channel has high latency, so it is desirable to minimize synchronization overhead and round-trips. In the case where it is not, my main priority is to identify the problem. I don't want to know why some form is problematic, I want to know which problem it is. With terse error messages there's a decent chance I'll memorize them over time, and recognise a given error message all at once by shape, rather than reading them word by word. Just as I memorize words and recognise them all at once, by shape, rather than letter by letter. * * * This conflict of 'why' vs 'which' is didactic. An inexperienced programmer might in fact want to know why their code is not working. But my own experience at this point is that, if it is not presently clear what is wrong with my code, what I need to study is my own code, not the error message.
- moonchild 5y ago> This does nothing for e.g. emoji, if there is disagreement about the version of unicode in use. Incidentally, this can be 'corrected' by making the compiler reset the cursor position to where it thinks it should be after drawing each grapheme. Is that really better than the alternative? Can we just kill this infrastructure already? ¯\_(ツ)_/¯