Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 exptools 1/6/84; site ihu1e.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!ihu1e!nowlin From: nowlin@ihu1e.UUCP (Jerry Nowlin) Newsgroups: net.lang.c,net.flame Subject: Re: 'op=' operators Message-ID: <326@ihu1e.UUCP> Date: Wed, 3-Oct-84 15:02:59 EDT Article-I.D.: ihu1e.326 Posted: Wed Oct 3 15:02:59 1984 Date-Received: Thu, 4-Oct-84 03:43:57 EDT Organization: AT&T Bell Labs, Naperville, IL Lines: 43 <.> > I am not sure how K&R specify that > *ptr++ += 2; > should be evaluated. Page 191 says only that the behaviour of E1 op= E2 > is the same as E1 = E1 op E2, but does that mean in this case > *ptr++ += *ptr++ + 2; > *ptr += *ptr++ + 2; > or > *ptr++ += *ptr + 2; ? (and what does the first form mean?) > > For out 4.2 bsd compiler, the last form is used, with the incrementation of > the pointer after the addition of 2. Is this guaranteed by the standard? > Robert (I hope you meant to use = instead of += in your attempts at clarification.) Excuse me, but this article reminds me of "Old McDonald Had a Farm." With a ++ here, and a ++ there. Here a +. There a +. Everywhere a ++. I think there should be a rule of style that says "If you can't figure out what a statement will do without trying it, rewrite it!" How about scanning: *ptr += 2; ptr++; Does anybody have a shred of doubt what that will do? If so try this: *ptr = *ptr + 2; ptr = ptr + 1; I certainly wouldn't go as far as the last example to make my code readable, but the "experts" that think up these clever little statements that take longer to decipher (six months down the road when one of them backfires) than rewriting the entire program should be forced to use COBOL for the rest of their lives! Jerry Nowlin ihnp4!ihu1e!nowlin