Article View: comp.std.c
Article #1367Re: for(;;) vs. while(1) is a draw
From: Karl Heuer
Date: Fri, 01 Jun 1990 16:34
Date: Fri, 01 Jun 1990 16:34
44 lines
2635 bytes
2635 bytes
In article <13025@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >... empty subject. There is no implementor dumb enough to attempt to make >such a claim ... This is why I said Blair's statements were vacuously true. Here's the recap, for those who tuned in late: * A lot of people don't really care whether you use for(;;) or while(1), and wish that such discussion, if it is to take place at all, should be in alt.religion.computers. * Blair happens to prefer while(1) for some reason. Most of us don't care why. * Evidently someone once told Blair of a compiler that produced slightly better code for the `for' statement. I believe I've seen such a compiler. * The better-code argument is pretty weak, since any compiler that overlooks such an obvious optimization is doing such a poor job that you'd better not be using it for anything where you care about compiler efficiency. At best, you can use this argument as a tie-breaker. (E.g. this is why I originally settled on using `++i' rather than `i++'.) * Blair noted that the ANS, in describing the `for' statement, uses wording that (correctly) describes `for(;;)' as equivalent to `while(1)'. He mistakenly thought that this wording was more than just a convenient way to describe the semantics, and used this to rebut the better-code argument. * It turns out the K&R 1 actually does contain a similar clause, not that it matters. * No sane vendor, in the process of upgrading a Classic C compiler to ANSI C, is going to change the way code is generated for `for' or `while' on the basis of this wording. Thus, it remains true that `for(;;)' is slightly less likely to generate a useless compare. * A lot of people don't really care whether you use for(;;) or while(1), and wish that such discussion, if it is to take place at all, should be in alt.religion.computers. Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint (Isn't this subject in your KILL file yet?)
Technical Details
Message-ID:
<16765@haddock.ima.isc.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!dali!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!ncar!ico!ism780c!haddock!karlReferences:
<5916@buengc.BU.EDU> <894@hadron.COM> <5926@buengc.BU.EDU> <13025@smoke.BRL.MIL>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!dali!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!ncar!ico!ism780c!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.std.c Subject: Re: for(;;) vs. while(1) is a draw Summary: The Show So Far Message-ID: <16765@haddock.ima.isc.com> Date: 1 Jun 90 16:34:30 GMT References: <5916@buengc.BU.EDU> <894@hadron.COM> <5926@buengc.BU.EDU> <13025@smoke.BRL.MIL> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 44