This is actually quite common practice, and for good reason. In C there was no try/catch so this was the cleanest way to write code that had a lot of error handling in it. The alternative would be to have a bunch of nested if/else statements that could get way out of hand if there were a lot of error conditions. Or you could do a return out of the function on an error but doing this is considered bad practice by a lot of people since it makes setting breakpoints while debugging all that much harder and it makes it impossible to have cleanup code at the end of the function. GOTO's are considered bad because they can cause really bad spaghetti code, however if they were used properly just for error conditions they could be a valid alternative to break; on error.
M
moardak
@moardak
0
Reputation
1
Posts
10
Profile views
0
Followers
0
Following
Best posts made by moardak
This user hasn't posted anything yet.
Latest posts made by moardak
-
RE: Gotos considered harmful, but break considered OK?