3 ms·
There's some evidence that indentation-based block delimiting is intuitive: People indent their blocks even in whitespace-insensitive languages.
by shrimpx 4y ago
There's some evidence that indentation-based block delimiting is intuitive: People indent their blocks even in whitespace-insensitive languages.
- majewsky 4y agoIndentation-based delimiting is good for reading because it provides visual structure. For writing, it's much more effective to rely on braces or parentheses instead and have the indentation be inferred by an autoformatter. For example, with braces, I can just copy-paste a statement or block of statements from somewhere else and it will have the correct semantics regardless of what indentation the source and destination end up having, and the autoformatter will immediately fix it for me.
- kazinator 4y agoWith indentation-only based delimiting, you don't know whether you're seeing the whole thing: def check(situation): if situation.under_nuclear_attack: situation.set_alert_level(RED) -------------- bottom of window ----------------- Is that the whole function? Does it forget to launch the counterstrike? Or is there more? We don't know without scrolling down. You can change the meaning of code, without changing its whitespace sensitive diff (git diff { -w | -b }).