Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucsfcgl.UUCP Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!ucsfcgl!arnold From: arnold@ucsfcgl.UUCP (Ken Arnold%CGL) Newsgroups: net.lang.c Subject: Re: C programming style Message-ID: <578@ucsfcgl.UUCP> Date: Thu, 18-Jul-85 18:23:03 EDT Article-I.D.: ucsfcgl.578 Posted: Thu Jul 18 18:23:03 1985 Date-Received: Sat, 20-Jul-85 05:56:09 EDT References: <11434@brl-tgr.ARPA> <303@ur-laser.uucp> <186@drivax.UUCP> Reply-To: arnold@ucsfcgl.UUCP (Ken Arnold) Organization: UCSF Computer Graphics Lab Lines: 28 In article <186@drivax.UUCP> braun@drivax.UUCP (Karl Braun) writes: >The comment regarding the effeciency of the >produced code is probably applicable to most compilers, but academically, any >reasonable optimizer should optimize 'i = i + 1' to equivelant code. (I have extracted this out of an article I otherwise agreed with completely, because this is not true, as will be elucidated below). This is quite true for such simple expressions as i = i + 1; but not true at all for such things as a[f()] = a[f()] + 1; which cannot be reduced to a[f()]++; Which is another reason why this can't be done. Another thing which ++ saves is typos. If you use i = i + 1; you must retype "i". This is fine when "i" is simple, but if it is a complex variable expression, you could get two legal expressions which are different instead of the same, and then not get the same effect (not to mention the efficiency). All in all, if "increment(i)" is more clear than "i++", you don't know C. Since ++ means "increment", nothing could be clearer. Or would you prefer "and", "or", "plus", "minus", etc.? Urg. Ken Arnold