Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!burl!codas!cpsc6a!rtech!wrs!dg From: dg@wrs.UUCP Newsgroups: comp.lang.c Subject: Re: Possible C Anomaly Message-ID: <370@wrs.UUCP> Date: Fri, 25-Sep-87 16:14:46 EDT Article-I.D.: wrs.370 Posted: Fri Sep 25 16:14:46 1987 Date-Received: Sun, 27-Sep-87 21:35:37 EDT References: <9270@brl-adm.ARPA> <5112@jade.BERKELEY.EDU> <682@hsi.UUCP> Reply-To: dg@wrs.UUCP (David Goodenough) Organization: Wind River Systems, Emeryville, CA Lines: 54 In article <682@hsi.UUCP> palmer@hsi.UUCP (Mike Palmer) writes: ]In article <5112@jade.BERKELEY.EDU>, mwm@eris.BERKELEY.EDU (Mike (My watch has windows) Meyer) writes: ]] In article <9270@brl-adm.ARPA> mrd@sun.mcs.clarkson.EDU (Michael R. DeCorte) writes: ]] < /* Example #1 */ k = (k > 1) ? k-- : 1; ]] < ]] < My intent was to decrement k with each pass until it reached 1 and then to ]] < keep it at one. There are a variety of ways to accomplish this but I just ]] < happened to try this one first. ]] ]] 1) ? --k : 1; ]] ]] No! Consider that you're doing (one way) "k = --k". You still don't know ] ]... stuff deleted ... ] ]] 1) ? (k - 1) : 1; ]] ]] Much better - it's right. ] ]why not just use ] ] (k > 1) ? k-- : (k = 1); ] ]or better yet ] ] (k > 1) ? k-- :; ] ] ]just my two cents. I've got my asbestos suit ready for the incoming flames, so I think I can safely ask "Why the addictive fixation on the -- operator for this case. Why not just say: k = (k > 1) ? k - 1 : 1; Lint likes it, there is no problem with order of evaluation etc. etc. etc. Alternatively why not try: if (k > 1) k--; Which is about as obvious an answer to what is required. -- dg@wrs.UUCP - David Goodenough ..... ihnp4!sun!decwrl!ucbvax!dual!wrs!dg +---+ | +-+-+ +-+-+ | +---+