Submitted by Dacadey t3_z89cro in explainlikeimfive
Deadmist t1_iycd9gz wrote
Reply to comment by Symbian_Curator in ELI5: why is using "goto" considered to be a bad practice in programming? by Dacadey
> In C, to mimic the destructor behaviour of C++ in function.
That doesn't mean using GOTO isn't bad, it just means that there is no better option in C.
In 'modern' languages, like C++ or Java, you can achieve the same outcome with destructors or try-with-resources, without the pitfalls of GOTO.
Symbian_Curator t1_iyce7cl wrote
I agree, but sometimes you just have to use C and then you use the tools you have. A bad tool is better than no tool at all.
My main point was that GOTO is not always pointless/useless.
Clewin t1_iyd736l wrote
Speaking of, one of the biggest uses of GOTO I saw in C was for exception handling. C++ as well, until try-catch blocks were added (and that varied by compiler until the late 1990s, early 2000s).
Viewing a single comment thread. View all comments