|
|
Richard wrote:
For such requirements, I have written - and
been satisfied with - code of the style:
*(i > 0 ? &aa : &b) = <complicated expression>;
Well done - you'll make maintainers very happy in years to come.
What on earth is wrong with
v= complex expr;
if(i)
aa=v;
else
b=v;
Same number of characters give or take too .... Easy to see
flow/assignment in a debugger too. Very easy to read.
There's nothing wrong with it except that it is a _statement_, while the
previous form is an _expression_. While I personally strongly prefer the
former in "normal" code, there are still quite a few expression-based
idiomatic tricks in C programming, which require the use of the
expression form.
I don't see the point in starting an argument about this. If at all, you
should probably direct your question to the authors of the language,
asking them why they introduced this "redundant" ?: operator in the
first place.
--
Best regards,
Andrey Tarasevich
|
|