|
|
|
|
|
by TuringTest
1261 days ago
|
|
You can't let the computer ensure the correctness of code. I replied to dismiss your assumption that adding delimiters as '}' or 'END' will ensure the correctness of code in a way that a code with indentation delimiters can't do. It's similar to saying that in, a language where statements are not finished by semicolon, it's not decidable where sentences end, so this forces the developer to decide on the correctness of statements. OF COURSE there are ways to define where a statement ends without adding a semicolon to each one, just like there are ways to decide where blocks end in an indent-based programming language; they are embedded in the language syntax. Heck, C is notorious for producing incorrect code for NOT using meaningful indentation and relying on delimiters instead. If you write: if (x>0)
function(1);
else
function(2);
And then you expand the else block: if (x>0)
function(1);
else
function(2);
function(3);
Then function(3) will be compiled out of the if sentence, when it's clearly part of the else block. |
|
But I'm not letting it do that, I'm letting the computer autoformat it, which it can't do if the whitespace is the code.
> Then function(3) will be compiled out of the if sentence, when it's clearly part of the else block.
And yet, I don't have to worry about that error because the editor is able to simply autoformat it so I can see where the error is even when the compiler/interpreter thinks it's legal code!
That's the whole point - using whitespace as part of the code means that the IDE can not, and never will be able to, autoformat the code.
Your example is one of a burden that falls to the programmer in Python, but is taken care off by the computer in other languages.
These errors, which can be automatically found by the computer in other languages, have to be manually found by the programmer in Python. It's a clear disadvantage.