By @BatVink:
Quote: "The only language I have needed to use goto in, is VBA (Visual Basic for Applications). This language is missing exit commands from loops.
This code:
do
//do stuff
if GetRawKeyPressed(27) then goto endProgram
sync()
loop
can be written as:
do
//do stuff
if GetRawKeyPressed(27) then exit
sync()
loop
I don't know the full technical details, but exit will do a tidier job than goto, which will leave rubbish on the stack."
Whilst certainly an improvement, arbitrary exit points is nearly as bad as arbitrary entry points (which is the real reason GOTO is pure distilled evil, as it combines both traits).
What I'd do is simpler and safer:
repeat
//do stuff
sync()
until GetRawKeyPressed(27)
Allthough to be honest, in a real world application, I'd extract all the input logic to some function, and set a flag that gets checked the status of at the end.
And since we've established a long time ago that GOTO is evil, it's little brother the GOSUB is at least deviously mischievous
Functions rules - at least in AppGameKit which doesn't have a trace of OO in tier 1. Not that that is a bad thing as such, but there is a tool in my box of tricks missing...