5 ms·
The hardest thing in programming for me is to control the control structures, where i must trace all the "goto" statements. The best experience that i've used
by revskill 4y ago
The hardest thing in programming for me is to control the control structures, where i must trace all the "goto" statements.
The best experience that i've used is Haskell, where there's no "goto".
- bee_rider 4y agoThere’s something really satisfying about having a working program, and then unlocking totally new functionality by just placing a sneaky goto, though.
- MattPalmer1086 4y agoI recently had to use a goto for the first time in years. Structured programming is fine, but almost no languages except python support the while...else construct. The semantics are to execute a loop body while the condition is true, and then to execute the else body when it isn't. But if you break out of the while loop, the else is not executed.
- sinuhe69 4y agoYou don’t have to use goto. Set a condition then check it accordingly in the block following the while block and all will be fine.
- MattPalmer1086 4y agoYes, that is another way, but it involves setting a value and another test for it. This is in the context of an extremely fast algorithm and the overhead here is not acceptable. It does not always hurt to use goto to implement the correct control flow when required.Arguably, the code is clearer as well. EDIT: I'd prefer to actually have a while else construct though!