Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!grebyn!ckp From: ckp@grebyn.com (Checkpoint Technologies) Newsgroups: comp.lang.c Subject: Re: cond. op. on ='s LHS Message-ID: <1991Feb13.223412.28254@grebyn.com> Date: 13 Feb 91 22:34:12 GMT References: <4155@cernvax.cern.ch> Organization: Grebyn Timesharing Lines: 29 In article <4155@cernvax.cern.ch> burow@cernvax.cern.ch (burkhard burow) writes: >I'm wondering if anyone has any comments on using: > > *(a==b?&c:&d) = 1; > >instead of: > > if (a==b) c=1; > else d=1; Sure, I have a comment. My own opinion, of course, since both are valid C and should produce identical results. In nearly all cases I would use the second form. It's easier to read. In fact I had to go over the first one twice to assure myself that it does what the second clearly states, and clarity is a critical feature of any program. Note also that the first form won't necessarily work if either c or d are register variables. The only time I would use the first form is in a macro, in a situation where I really wanted an expression rather than a statement. But that's all. -- First comes the logo: C H E C K P O I N T T E C H N O L O G I E S / / \\ / / Then, the disclaimer: All expressed opinions are, indeed, opinions. \ / o Now for the witty part: I'm pink, therefore, I'm spam! \/