On Monday, 24 March 2014 at 02:21:20 UTC, Kenji Hara wrote:
2014-03-24 10:38 GMT+09:00 Daniel Murphy <[email protected]>:

"Kenji Hara" <[email protected]> wrote in message
news:[email protected]...

2014-03-24 10:09 GMT+09:00 bearophile <[email protected]>:

if (cond) exp1, exp2; // in most case, this is not a bug.


It's not a bug, but this does the same thing - so why use the comma
operator?

if (cond) { exp1; exp2; }

It catches bugs that are otherwise very difficult to spot.


At least I can imagine two reasonable cases.

1. If the code is ported from C/C++, breaking it is not reasonable.

Kenji Hara

What about the compiler make some effort to detect this usage and suggests the appropriated solution? just like it does when using C's array/cast style. i.e., split the expression separed by the comma operator in a list of expressions separed by semicolon inside a compund statement. It isn't too hard to implement.

Reply via email to