D
Daniel T.
Chris Dollin said:Keith said:It's ugly.
Eye of the beholder, and all that - it looks fine to me ...
It would be better written as
if (condition) {
expression1;
expression2;
}
... whereas /that/ looks ugly to me [always assuming, of course, that
the expressions will fit comfortably as written].
The comma operator can be useful because it can be used in a larger
expression expression
`E1, E2` is larger than either of `E1` and `E2`, but I don't see why
that matters; the comma operator is useful because it can /combine/
expressions into bigger expressions ...
and because it yields the value of its right operand.
... and has a particularly simple evaluation rule.
Here it's not being used in a larger expression, and the
result is being thrown away.
The results of many expressions in C are thrown away, but that
doesn't make it wrong to use them as the then-part of an if-statement.
I was hoping for something more concrete than "it's ugly". Otherwise
it's just a discussion about style, and we can all pick our own.
*Just* a discussion about style? "It compiles" is not the sole
justification for using a particular construct. If you disagree, try
maintaining some winners of the obfuscated code contest.