News for hackers. Stuff that matters.
Re:The History, Controversy, and Evolution of the Goto State... by praptak on Monday November 19, 2018 @02:11AM (#18484641)
For a relatively recent problem caused by use of goto: https://en.m.wikipedia.org/?title=Goto_fail
Re:The History, Controversy, and Evolution of the Goto State... by zzo38computer on Monday November 19, 2018 @02:17AM (#18484658)
That is not specific to do with a goto command itself; even if you wrote "break" instead of "goto fail", still the second one is unconditional. But either way, can easily seen that such program is not sense, so, easily to be noticed.

"There are several good coding practices that could have prevented this fault from occurring, such as code reviews, the proper use of indentation or curly braces, and test coverage analysis." Yes, it is true, whether you use goto or not, whether indentation-sensitive syntax is used or not, etc.

Re:The History, Controversy, and Evolution of the Goto State... by RustHacker on Monday November 19, 2018 @06:13AM (#18485592)
Break is technically a goto, albeit a nicer, more well behaved version thereof.
Re:The History, Controversy, and Evolution of the Goto State... by goto11 on Monday November 19, 2018 @07:51AM (#18486018)
'if' is also technically a goto then.
Re:The History, Controversy, and Evolution of the Goto State... by 13of40 on Monday November 19, 2018 @11:34AM (#18487548)
Earlier this year I spent some time implementing a BASIC (actually VBA) interpreter and to support error handling (e.g. ON ERROR GOTO foobar) I ended up translating all of the flow control statements into conditional GOTOs.
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.
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.

Re:The History, Controversy, and Evolution of the Goto State... by robotnik on Monday November 19, 2018 @05:06AM (#18485273)
The editor should have indented that line correctly.
Re:The History, Controversy, and Evolution of the Goto State... by Sniffnoy on Monday November 19, 2018 @02:14AM (#18484650)