View Single Post
Old October 17, 2017, 22:56   #24
kandrc
Swordsman
 
Join Date: Dec 2007
Posts: 295
kandrc is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
There is another way, but it's not a lot better than GOTO:
Code:
do {
     ...
     return;
} while (false);
Handle exception here
By "not a lot better", I think you mean "a lot worse". This solution doesn't handle the fall-through, reverse-ordered de-init that is (sometimes, often) necessary. Goto gets you that for free. I (and most old systems programmers like myself) would argue that this is not only an "acceptable" or "not bad" use of goto, but that it's actually good and elegant. It's certainly more elegant than exception handling in C++ or other "modern" languages unwinding my stack (yes, I know that many will argue with this claim, but not old systems programmers).

ITT: "Fixing" things that aren't broken.
kandrc is offline   Reply With Quote