Subject: Re: Time to update KNF?
To: Ted Lemon <>
From: Curt Sampson <>
List: tech-kern
Date: 01/20/2000 12:30:38
On Wed, 19 Jan 2000, Ted Lemon wrote:

> > When I'd need cleanup first, I have a cleanup section
> > at the end of the function (behind the normal return) that does all the
> > cleanup that is needed and returns, and I goto there.
> Me too.   It's a dirty little habit, but sometimes a geek's gotta do
> what a geek's gotta do... :')

What's so dirty about it? Gotos were deprecated for a long time because
often the code the were used in was easier to understand when it was
rewritten with a loop construct.

On the other hand, there are situations where the code is clearer and
easier to follow if a goto is used. (This is usually where one has to
do the same exit cleanup should any of a number of tests fail, and in
finite state machines, I find.) If you think the goto is dirty, rewrite
your code not to use it and see how dirty it gets. (Well, you know this
already, or you wouldn't be using the goto.)

Some languages have constructs that can help avoid these gotos, such as
Java's try/catch/finally statements. C doesn't, unfortunately.

I think it's time for the rehabilitation of the goto! In fact, perhaps
I should start a Society for the Rehabilitation of the Goto Statement. :-)

Curt Sampson  <>   917 532 4208   De gustibus, aut bene aut nihil.
The most widely ported operating system in the world: