Re:The History, Controversy, and Evolution of the Goto State...
by goto11 on Monday November 19, 2018 @03:23AM
(#18484869)
The problem is not caused by the use of goto though. It could have been any other statement and it would still be a bug. The problem is lack of braces or the misleading indent. If anything this example is a case for Python, not a case against goto.
[ Parent
| on HN ]
Re:The History, Controversy, and Evolution of the Goto State...
by coldtea on Monday November 19, 2018 @03:32AM
(#18484899)
>If anything this example is a case for Python, not a case against goto.
You'd be surprised how many times I've got the indentation wrong in Python.
If a body gets > 20 lines or so, it's easy to miss one statement that ought to be intended.
Re:The History, Controversy, and Evolution of the Goto State...
by yesenadam on Monday November 19, 2018 @03:56AM
(#18484989)
that ought to be intended.
That ought to be "indented".
Re:The History, Controversy, and Evolution of the Goto State...
by coldtea on Monday November 19, 2018 @06:54AM
(#18485759)
Yeah, that mistake was inindented
Re:The History, Controversy, and Evolution of the Goto State...
by yesenadam on Monday November 19, 2018 @04:15PM
(#18489810)
Sometimes (like now) I wish I could give a +10 or +100 on HN! Thank you :-)
Re:The History, Controversy, and Evolution of the Goto State...
by int_19h on Monday November 19, 2018 @04:31AM
(#18485121)
This example is a case for languages where the bodies of conditionals, loops etc are required to have a terminator. Python is technically one of them, but probably not the best one, because terminator is the DEDENT pseudo-token, and because it's just whitespace, it can be easy to miss.
The best examples are languages like Lua and Ruby, where you have to write it as if .. then .. end or if .. then .. else .. end. Alternatively, in the curly brace family, it's the ones that make braces mandatory in this situation, like Go - if ... { ... }.
Re:The History, Controversy, and Evolution of the Goto State...
by goto11 on Monday November 19, 2018 @06:57AM
(#18485778)
Agree, and I am paranoid enough to always use braces for single statement bodies. I also think this is recognized as a flaw in C-style syntax, and newer languages like Rust mandate the braces.
I do think Python has the simplest and most logical solution though.