Andreas wrote:
The most flexible but safe solution is to simply define the indentation as the sequence of indentation characters used. Two consecutive lines are indented consistently whenever one indentation is a prefix of the other. Hence you may freely mix different indentation characters, but you must be consistent across lines. Any decent editor should be able to ensure that.
Well no they won't, because some editors might replace blocks of 8 spaces at the start of a line with TABs (or something like that), meaning that 8 and 7 spaces would go to "\t" and " ", which your algorithm would reject. On the other hand, so would mine, so perhaps your algorithm is better, being simpler Simon Marlow wrote:
As for the width of the tab character: tab stops are every 8 columns. Period. The Haskell report says so
Yes, true. I think it was Leslie Lamport who wrote in TeXHaX that anyone defining an input format which includes tabs should be sentenced to ten years programming COBOL in Nijny-Novgorod. Off you go, Simon ... :)
George Russell wrote:
The most flexible but safe solution is to simply define the indentation as the sequence of indentation characters used. Two consecutive lines are indented consistently whenever one indentation is a prefix of the other. Hence you may freely mix different indentation characters, but you must be consistent across lines. Any decent editor should be able to ensure that.
Well no they won't, because some editors might replace blocks of 8 spaces at the start of a line with TABs (or something like that), meaning that 8 and 7 spaces would go to "\t" and " ", which your algorithm would reject.
If the editor does the replacement consistently everywhere (like I would expect) then it would not change the meaning of a "well-indented" program. - Andreas -- Andreas Rossberg, rossberg@ps.uni-sb.de "Computer games don't affect kids; I mean if Pac Man affected us as kids, we would all be running around in darkened rooms, munching magic pills, and listening to repetitive electronic music." - Kristian Wilson, Nintendo Inc.
Andreas Rossberg wrote:
The most flexible but safe solution is to simply define the indentation as the sequence of indentation characters used. Two consecutive lines are indented consistently whenever one indentation is a prefix of the other. Hence you may freely mix different indentation characters, but you must be consistent across lines. Any decent editor should be able to ensure that.
Well no they won't, because some editors might replace blocks of 8 spaces at the start of a line with TABs (or something like that), meaning that 8 and 7 spaces would go to "\t" and " ", which your algorithm would reject.
If the editor does the replacement consistently everywhere (like I would expect) then it would not change the meaning of a "well-indented" program.
Yeah, but it probably won't. More likely, it will only perform the replacement on the lines which you actually edit, and leave the rest of them alone. -- Glynn Clements <glynn.clements@virgin.net>
George Russell wrote:
Simon Marlow wrote:
As for the width of the tab character: tab stops are every 8 columns. Period. The Haskell report says so
Yes, true. I think it was Leslie Lamport who wrote in TeXHaX that anyone defining an input format which includes tabs should be sentenced to ten years programming COBOL in Nijny-Novgorod. Off you go, Simon ... :)
At least that gives the compiler writers a standard to work from. Then they can say 'well if you don't consider tabs to be eight columns, then it's your fault your code doesn't work'. Although I'm inclined to agree with Lamport - mostly in the case of Makefiles because they're required, but tabs in C++ code drive me up the wall, across the ceiling and out the window on the other side.
participants (4)
-
Andreas Rossberg -
George Russell -
Glynn Clements -
Matthew Walton