News for hackers. Stuff that matters.
Re:Loop Exits and Structured Programming: Reopening the Deba... by mjevans on Monday June 12, 2017 @10:15PM (#14542484)
goto is best viewed as a low level (unsafe) operation.

I wouldn't mind it if the language expressly made me call such a function from a library of other 'unsafe' operations. Optional things that you can include when you really know what you're doing and use them in a limited way.

It's one of those tools that is powerful, dangerous, and best avoided when another will suffice. Yet like explosives, sometimes dangerous is the best tool for a job.

In the case of a programming language goto can be used to emulate features and/or paradigms that a language doesn't have or doesn't quite do sufficiently. It should ALWAYS have a comment that annotates the intent.

Re:Loop Exits and Structured Programming: Reopening the Deba... by dingo_bat on Monday June 12, 2017 @10:31PM (#14542532)
How is goto an inherently unsafe operation? As long as the usage is clear, it's as safe as any other logical instruction. Problems pop up when nobody else is able to read your code and fix a bug. I feel bad because it has been drilled into my head from the start that goto is unconditionally bad. So I never use it. But I saw a friend replace my spaghetti jungle of break and continue with a simple and clear flow using goto. It was a real mind blowing moment.
Re:Loop Exits and Structured Programming: Reopening the Deba... by mjevans on Monday June 12, 2017 @11:01PM (#14542607)
It's 'unsafe' like how working with raw pointer arithmetic is 'unsafe'. It escapes the paradigms offered to provide regular flow and might also require the compiler to restrict how it handles those sections of code. As others have pointed out elsewhere, it also affects how humans interpret the code, thus it is more likely to be related to bugs as well.
Re:Loop Exits and Structured Programming: Reopening the Deba... by glangdale on Tuesday June 13, 2017 @07:05PM (#14549419)
It is not remotely unsafe the way that raw pointer arithmetic is unsafe. Proving things about what raw pointer arithmetic winds up doing is undecidable; non-computed goto, on the other hand, is completely obvious. On the theory side, at worst you can create nasty irreducible flow-graphs where you can't simply put code on 'edges', but this is pretty minor. It is very unlikely that a compiler is going to go into the weeds from a local goto; you are spreading FUD.

Exceptions, on the other hand, or non-local goto, has a good chance of seriously scrozzling compilers and causing a lot of optimizations to go away.

All that being said, the potential to break human understanding of the code with gotos is serious.