On 14/01/2018 2:18 AM, Paul Gilmartin wrote:
    ...
I prefer implicit destruction of resources. It takes careful programming
in C to handle errors and free resources that usually requires lots of
code. I've always found the best way
to do that in C is a goto that branches to a cleanup block but oddly
that seems to be banned by most company coding standards. ...

"break"  almost suffices.  Alas, C, unlike Rexx, provides no way to exit a
specific block.

An alternative is a wrapper procedure:
     acqire resources
         call main body code
     cleanup

Not as clean as a goto, especially in deeply nested code. Using goto for control structures is poor practice but for error handling in languages that don't support exceptions it remains the best solution. Exceptions, break, continue are just syntactic suger for goto.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to