Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!gatech!hubcap!beede From: beede@hubcap.UUCP (Mike Beede) Newsgroups: comp.lang.c Subject: Re: Style [++i vs i++] Message-ID: <246@hubcap.UUCP> Date: Tue, 30-Jun-87 19:50:24 EDT Article-I.D.: hubcap.246 Posted: Tue Jun 30 19:50:24 1987 Date-Received: Wed, 1-Jul-87 07:14:36 EDT References: <17310@amdcad.AMD.COM> Organization: Clemson University, Clemson, SC Lines: 23 in article <17310@amdcad.AMD.COM>, tim@amdcad.AMD.COM (Tim Olson) says: > > [ question: use ++i or i++ when only side-effect is desired ] > > Personally, the use of post-increment operators here drives me crazy. They > have the added meaning of returning the value of the incremented lvalue > before the increment. If this is just thrown away, why do it? ^-------------------------------------^ Just an observation: all expressions in C return a value. Thus, every ``naked'' expression involves throwing a value away (++i; AND i++;). There is no reason a compiler needs to generate code differently for i++; and ++i; if that is the entire expression (and statement). Maybe some people familiar with the internals of C compilers could comment on this--it may be easier to generate different code for these cases. BTW--I use ``i++''. For me that seems more natural--maybe from using HP calculators for many years (1/2 ;-> ). -- Mike Beede UUCP: . . . !gatech!hubcap!beede Computer Science Dept. ARPA: BEEDE@TECNET-CLEMSON.ARPA Clemson University INET: beede@hubcap.clemson.edu Clemson SC 29631-1906 PH: (803)656-{2845,3444}