3 ms·
> In go, with the semi-colon insertion rules and with gofmt, there is an implicit whitespace rule all over again. So this is technically correct (and I had nev
by vanderZwan 13y ago
> In go, with the semi-colon insertion rules and with gofmt, there is an implicit whitespace rule all over again.
So this is technically correct (and I had never though about that before, so thank you for pointing that out!). However, I think '\n' and '\r' are not directly comparable to '\t' and ' ' characters.
All whitespace is only visible by its boundaries (kinda like certain 70s minimalist sculpture, actually). Newlines affect vertical structure, whereas tabs and spaces affect horizontal structure. So far it's the same.
However, we don't read text vertically, we read it horizontally (I know there are exceptions, but not in any significant programming languages that I know of). As a result we don't group characters by vertical whitespace the same way as we group characters by horizontal whitespace: in most natural languages, the difference is paragraph separation vs word/sentence separation. Programming languages also follow this coarse/refined level. Think about how we construct indented text in programming languages: relative to the vertical position.
So I would say that while both cases have the problem that we can only observe whitespace by the characters that surround them, in the vertical whitespace that happens at a coarser, less ambiguous level than horizontal whitespace. And I think that's why using significant newlines should be less failure prone than significant tabs/spaces.
- dragonwriter 13y ago> However, we don't read text vertically, we read it horizontally (I know there are exceptions, but not in any significant programming languages that I know of). I think we do read code vertically and it is significant in all programming languages, and I think that it is a core problem with acceptance of Lisps, because they unusually strongly avoid leveraging the two-dimensional nature of typical code editing environments in favor of having pretty much the perfect purely-horizontal syntax. > So I would say that while both cases have the problem that we can only observe whitespace by the characters that surround them, in the vertical whitespace that happens at a coarser, less ambiguous level than horizontal whitespace. I do think there is an ambiguity difference, but its not because we read horizontally but not vertically, but because horizontal whitespace in common use -- i.e., that people are used to using on a keyboard in the context of programming -- is limited to newlines (and, while there are different means of expressing newlines, they are mostly driven by platform rather than personal preference and are, in any case, easy to account for), whereas tab/space holy wars are as old as line oriented PLs that allow indentation (whether they are sensitive to it or not).
- vanderZwan 13y ago> I think we do read code vertically and it is significant in all programming languages Of course it is significant, I was agreeing with you there! But my point was: d o _ y o u _ e v e r _ w r i t e _ c o d e _ l i k e _ t h i s ? But maybe I should have worded it differently: we read text in "row-major order", not "column-major order". That's basically the difference I talk about. Also, there is another difference between newlines and indentation: newlines only go "forward" (next line), whereas with indentation you go back and forth into levels of indentation. It's not the same. The closest thing I can think of is that one language where you could write the exponent of a formula on a line before, faking superscript, or the index of a formula on the next, faking subscript. Making mono-typed source code look like math formulas basically (and probably a pain to type out). That's the only programming context I can think of where newlines are actually significant in a similar fashion to indentation.