At 11:37 PM 1/14/99 -0800, Sam Ismail wrote:
>
>Remember, C has a goto statement, although I don't think in my nearly 10
>years of C programming I've ever used it, although on certain rare
>occasions it seemed the easy way out to a sticky coding problem.
> [...] but C really suffers from a lack of
>a general error trapping mechanism that one can invoke to break out of
>loops as required. Sometimes I think goto's are the answer but I can
>never find an appropriate way to implement it.
I use "goto" in C on a regular and consistent basis for error exceptions:
USHORT firstFunction( void )
{
USHORT lerr;
if ((lerr=secondFunction()) != TE_NOERROR) {
goto out;
}
out:
return lerr;
}
The benefit is that all functions propogate an error code, any
function can fail, and all functions clean up after themselves
after their "out" label.
- John
Received on Fri Jan 15 1999 - 10:00:07 GMT
This archive was generated by hypermail 2.3.0
: Fri Oct 10 2014 - 23:32:06 BST