cond. op. on ='s LHS

Wayne Throop throopw at sheol.UUCP
Sun Feb 17 00:48:04 AEST 1991


- gwyn at smoke.brl.mil (Doug Gwyn)
-- rh at smds.UUCP (Richard Harter)

-- [.. some context restored ..]
--       *(a==b?&c:&d) = <some complicated messy expression>
-- However the ugly one liner is better code in the sense of not having
-- replications of a single term or in using temporaries.  [...] In
-- principle the idea is a good one but the C conditional expression is
-- just too darned ugly. 
- There are good ways of exploiting the ?: operator and bad ways.
- The example being discussed is clearly among the latter.

I'm not sure I understand.  Could either Doug or Richard expand a little
on just why the expression is "ugly" or a "bad way" to exploit the
conditional operator?  It doesn't seem any worse than, say

         foo[a==b?c:d] = something;

or even just

         foo[(a+b)*(c+d)] = something;

or the like.  All are examples of a complicated decision going into
exactly which object is going to be assigned to.  Granted, the
conditional is more extreme than the subscripting examples, but not to
any large degree IMHO.  So why is the explicit conditional any worse
than the others?

( Note: the restored context above may have obliterated the "example
        being discussed" by Doug.  If the example I left there isn't
        the one he means, forgive me. )
--
Wayne Throop <backbone>!mcnc!rti!sheol!throopw or sheol!throopw at rti.rti.org



More information about the Comp.lang.c mailing list