Article View: comp.arch
Article #91Re: A challenge to the anti-goto Was: Re: Hardware Support for Numeric Algorithms
From: Shankar Unni
Date: Fri, 30 Oct 1992 23:02
Date: Fri, 30 Oct 1992 23:02
43 lines
1978 bytes
1978 bytes
Herman Rubin (hrubin@pop.stat.purdue.edu) wrote:
> I would like to see how you anti-gotos would write code of the following
> type so that either a human being could understand it
> extern B;
> n = 0; m = 0; b = B;
> {goto start;
> case 1: n += 1;
> case 3:
> [ ... ]
> case 12:
> start: g = ....;
> switch(g){
> case 2: goto label1;
> case 4: goto label2;
> case 7: g4 = 1; goto label3;
> case 8: h = ...; g4 = h>>1; if(h&1){g4+=2; goto label3;} goto label4;
If anyone around here (read: "real world" (tm)) wrote code like that,
he or she would be fired pronto, and the code sent into the bit
bucket.
Dr. Rubin, this sort of code may be OK for one of your throwaway
research projects, but around these parts, people tend to move around
from job to job, and I pity the poor slob who had to maintain crap
like this.
Sometimes, giving up 5% of the cycles in order to get clean, readable
code with a reasonably clear flow of control is a perfectly acceptable
tradeoff.
If the loops get nested too deeply to be able to break out of neatly,
it is time to restructure the code (break it up, break off some code
into functions, etc.).
After all, next year, all the CPUs will be 25% faster, whereas the
code may have to be maintained, and worse, modified, for years and
years to come.
--
Shankar Unni E-Mail: shankar@sgi.com
Silicon Graphics Inc. Phone: +1-415-390-2072
Technical Details
Message-ID:
<1cseutINNk30@fido.asd.sgi.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!concert!uvaarpa!darwin.sura.net!jvnc.net!yale.edu!think.com!ames!olivea!sgigate!odin!fido!shankarReferences:
<BwxsF6.3DF@mentor.cc.purdue.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!concert!uvaarpa!darwin.sura.net!jvnc.net!yale.edu!think.com!ames!olivea!sgigate!odin!fido!shankar From: shankar@sgi.com (Shankar Unni) Newsgroups: comp.arch,comp.lang.misc Subject: Re: A challenge to the anti-goto Was: Re: Hardware Support for Numeric Algorithms Message-ID: <1cseutINNk30@fido.asd.sgi.com> Date: 30 Oct 92 23:02:53 GMT References: <BwxsF6.3DF@mentor.cc.purdue.edu> Organization: Silicon Graphics, Inc. Lines: 43 NNTP-Posting-Host: boris.wpd.sgi.com X-Newsreader: Tin 1.1 PL5