M
Mark McIntyre
On 14 Dec 2005 03:51:59 -0800, in comp.lang.c , Tim Rentsch
(on the topic of the 'niceness' of)
Perhaps, once suitably parenthesised so that future maintenance drones
can understand it easily and w/o recourse to a manual of operator
precedence.
And it'd be a bit different if it were
foobar = (banana(12,34,pip(),333, printf("hello"))&&z)==blabla(bl,pl,
ypr)?pfngetarraycnt(yaddayadda,4) : atoi(getstringfrom(ww));
which is technically also a single assignment.
Of course. Some people /like/ obfuscated code
YMMV.
(on the topic of the 'niceness' of)
buffer = (n & j) == j ? '1' : '0';
The original single assignment is precisely the sort of situation
where using the ?: operator makes sense.
Perhaps, once suitably parenthesised so that future maintenance drones
can understand it easily and w/o recourse to a manual of operator
precedence.
And it'd be a bit different if it were
foobar = (banana(12,34,pip(),333, printf("hello"))&&z)==blabla(bl,pl,
ypr)?pfngetarraycnt(yaddayadda,4) : atoi(getstringfrom(ww));
which is technically also a single assignment.
If Mr. McIntyre says he
finds the if/else form with two assignments more readable, I'm expect
that's so, but his reaction isn't shared by everyone.
Of course. Some people /like/ obfuscated code
IMO the
single assignment using ?: is both more readable and more clear
than using if/else and two assignments.
YMMV.