I miss GOTO. It was unnecessarily expunged from the
programmmer's toolbox
by elitist academics.
It's a tool. Why, I discussed this with a "Sam Ismail" back in 1999:
- John
Date: Fri, 15 Jan 1999 16:00:07 +0000
To: classiccmp at
u.washington.edu, <dastar at ncal.verio.com>
From: John Foust <jfoust at threedee.com>
Subject: Re: Computers for children
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