5 ms·
I'm working on a text editor that automatically formats the code, it will have trouble with significant whitespace if the code is valid both with and without wh
by z3t4 9y ago
I'm working on a text editor that automatically formats the code, it will have trouble with significant whitespace if the code is valid both with and without white-space, and even compiles, and even runs with or without, although with a possible hidden bug. I've never worked with a language with significant whitespace so I'm wondering, does it create bugs!? In my experience, bad formatting can cause bugs, or is annoying, eg. syntax errors like "missing bracket" and you got no idea where it's missing, which is why my editor does the indentation automatically and enforce it (you can't change it).
- hibbelig 9y agoWell, significant whitespace will play the role of braces, right? You can't have your editor "fix" the braces, either -- the author has to put them in. In the same way, you can't have your editor "fix" the indentation -- the author has to put it in. But with braces, you can do consistency checks, such as that they are properly nested. In a similar way, you can do consistency checks with indentation. For example: line 1 line 2 line 3 The third line is wrong, the transition from line 1 to line 2 introduced an indentation step, and the third line is neither left nor right.
- z3t4 9y agoI find adding braces much easier then managing white space though. For example commenting out code, adding branches, removing branches etc.