Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Sep 1995 15:43:58 +0100 (BST)
From:      Karl Strickland <karl@bagpuss.demon.co.uk>
To:        Nate Williams <nate@rocky.sri.mt.net>
Cc:        terry@lambert.org, davidg@root.com, hackers@freefall.freebsd.org
Subject:   Re: Coding style ( was Re: why is this not a bug in namei?)
Message-ID:  <199509191443.PAA15358@bagpuss.demon.co.uk>
In-Reply-To: <199509190433.WAA24091@rocky.sri.MT.net> from "Nate Williams" at Sep 18, 95 10:33:01 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> > This "anti-goto-political-correctness-bullshit" has to go.  Anyone who
> > thinks a for loop generates prettier assembly than an label/if/goto
> > had better read more compiler output.
> 
> Huh?  I am in *complete* agreement with David here.  I have looked at
> *thousands* if not *millions* of lines of code in my years in
> programming.  Although there are times when gotos are necessary AND they
> improve readability, they are the exception rather than the rule.  When

I think, that like other tools, goto's have their place.  When something
else is better, like a for loop or a while loop, goto is bad news.  But
goto can be good news for exiting functions under exceptional circumstances,
or breaking out of >1 loop - much better than a chain of if() break; statements
IMHO.

> I see two gotos in a single function it is my opinion that the author
> has not spent the time to write the code in a readable manner.  Now,
> there may be a completely valid reason for it, but it will take a lot
> for me to believe that. :)
> 
> A rule enforced in all software houses I've worked in.  "Programmers who
> use gotos will be publically ridiculed"

If anyone laughed at me based on a rule like this, I'd think it said more
about them than about me.  There are plenty of garbage rules in software
houses laid down by managers who know no better.  I cannot take rules like
that seriously.

> > A goto is a tool for handling an exceptional conditions.  And that's
> > where goto's are use in my code.
> > 
> > The alternative is negative comparison code blocks, ie:
> > 
> > 	if( !(error = foo()) {
> > 		[real code]
> > 	} else {
> > 		[error code]
> > 	}
> 
> I prefer this to using gotos simply because my mind is tuned for
> parentheses, not goto statements.  It's a matter of what you are used to
> seeing.

All a question of taste :-)

-- 
------------------------------------------+-----------------------------------
Mailed using ELM on FreeBSD               |                    Karl Strickland
PGP 2.3a Public Key Available.            | Internet: karl@bagpuss.demon.co.uk
                                          |



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199509191443.PAA15358>