On Wed, 2005-05-11 at 21:56 -0500, Cmurray wrote:
I absolutely concur with John's conclusion:
Academia, the elites or otherwise, saw the 'horrors' of goto and declared it
an evil that was to be expunged from any language. The toolbox was
diminished by this action in my humble opinion. Yet for us QBasic guys we
still employ it. Boy does it get one out of a jam. Mimics real life doesn't
it?
Actually goto and it's ilk (continue, break, ...) are extremely useful
and when used properly can actually improve readability and
maintainability of code.
The best example is for use in an error path were some (a lot?) of
cleanup needs to be done. I assert that having the cleanup code
replicated 4 or 5 (or ??) times is *less* clear and *less* maintainable
than having the cleanup code (at the end of the function) once and all
of the error paths "goto" it.
For example:
if (p == NULL) {
rc = RC_P_NULL;
goto err_exit;
}
...
if (q == NULL) {
rc = RC_Q_NULL;
goto err_exit;
}
...
err_exit:
if (p != NULL)
free(p);
if (q != NULL)
free(q);
return(rc);
Computing forever!
Murray
On Wed, 11 May 2005, John Foust wrote:
> Speaking as that voice from the future,
reading ALGOL makes
> me say "You don't want to do it that way." GOTO had not yet
> been exorcised. Did I see a computed goto, where the expression
> calculates the label? Eeek. Certainly it was a step forward,
> but we've also learned a lot since then. When people complain
> that computer languages haven't changed much, remind them
> of the stuff that's fallen out of recommended practice.
I miss GOTO. It was unnecessarily expunged from the programmmer's toolbox
by elitist academics.
--
TTFN - Guy