cond. op. on ='s LHS

Michael Henning michi at ptcburp.ptcbu.oz.au
Fri Feb 15 10:28:25 AEST 1991


burow at 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;


Yes, I do :-)

If you compare the two above statements, the answer should be obvious.
The second expression is perfectly clear and readable, whereas the first
one takes some looking at to decipher.
Besides, on many compilers, the first expression will take longer to run,
since you are dereferencing a pointer there.

							Michi.
-- 
      -m------- Michael Henning			+61 75 950255
    ---mmm----- Pyramid Technology		+61 75 522475 FAX
  -----mmmmm--- Research Park, Bond University	michi at ptcburp.ptcbu.oz.au
-------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA	uunet!munnari!ptcburp.oz!michi



More information about the Comp.lang.c mailing list