cond. op. on ='s LHS

David Dick drd at siia.mv.com
Wed Feb 20 07:57:06 AEST 1991


In <326 at smds.UUCP> rh at smds.UUCP (Richard Harter) writes:

>In article <15184 at smoke.brl.mil>, gwyn at smoke.brl.mil (Doug Gwyn) writes:
>> In article <11073 at pasteur.Berkeley.EDU>, johnm at cory.Berkeley.EDU (John D. Mitchell) writes:
>> - In article <4155 at cernvax.cern.ch> 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;

>Seriously, there is a germ of a good idea here.  The example is inane,
>but consider

>	*(a==b?&c:&d) = <some complicated messy expression>

>One really doesn't want to code in said messy expression twice, so one
>tends to write something like

>	temp = <some complicated messy expression>
>	if (a==b) c = temp;
>	else      d = temp;

I believe that the result of a conditional expression 
is explicitly defined to be an r-value, so that
it cannot be assigned into.

David Dick
Software Innovations, Inc. [the Software Moving Company(sm)]



More information about the Comp.lang.c mailing list