On Friday, 27 July 2012 at 01:45:35 UTC, Jonathan M Davis wrote:
Now, we have way more safe constructs for moving around in code
then was the case when goto was originally vilified,
and everyone is using those constructs rather than goto.
But the stigma remains and everyone is used to thinking of goto
as evil.
So if everyone uses these other constructs, why even provide a
goto? I seriously have not needed a goto in over ten years; and
the way I see it, if your program uses one, it needs to be
refactored. Just my opinion.
It's a useful construct when used properly. It just shouldn't
be used when
there are better alternatives.
I can't think of ANY situation where goto would be the only
viable option. Loops, ifs, switches - these cover 100% of
requirements, surely? If it really is necessary in some cases,
how have I managed to avoid goto for so long? And what are these
cases?