From owner-freebsd-hackers Wed Sep 20 02:22:30 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id CAA26012 for hackers-outgoing; Wed, 20 Sep 1995 02:22:30 -0700 Received: from disperse.demon.co.uk (disperse.demon.co.uk [158.152.1.77]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id CAA26002 for ; Wed, 20 Sep 1995 02:22:21 -0700 Received: by disperse.demon.co.uk id ab23056; 20 Sep 95 6:36 +0100 Received: from post.demon.co.uk by disperse.demon.co.uk id aa20468; 20 Sep 95 0:41 +0100 Received: from bagpuss.demon.co.uk by post.demon.co.uk id aa28965; 20 Sep 95 0:38 +0100 Received: (karl@localhost) by bagpuss.demon.co.uk (3.1/3.1) id PAA15358; Tue, 19 Sep 1995 15:43:59 +0100 From: Karl Strickland Message-Id: <199509191443.PAA15358@bagpuss.demon.co.uk> Subject: Re: Coding style ( was Re: why is this not a bug in namei?) To: Nate Williams Date: Tue, 19 Sep 1995 15:43:58 +0100 (BST) Cc: terry@lambert.org, davidg@root.com, hackers@freefall.freebsd.org In-Reply-To: <199509190433.WAA24091@rocky.sri.MT.net> from "Nate Williams" at Sep 18, 95 10:33:01 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 2127 Sender: owner-hackers@FreeBSD.org Precedence: bulk > > 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 |