Comment Re:Very different code (Score 1) 225
No, the specs shouldn't be restricted for style reasons. I believe that the permissive specs and "undefined behaviors" are part of what made C and later C++ so successful.
I hate it when languages try to dictate how I should code when there are no technical reasons. My beliefs are that languages should be designed for experts, not for preventing beginners from shooting themselves in the foot. For this, there are compiler warnings, coding standards, static analysis tools,
Now let me tell you a few reasons why "if (a = b)" is better than "a = b;" followed by "if (a)" :
- An extra line takes up screen real estate, which is precious.
- In the two line version, "a" is written twice instead of once. It goes against the principle of code factorization.
Of course there are arguments going against it but it is just to show that it is not clear cut. Personally, I would use "if ((a = b))" : it gets rid of the warning, it's a common way of showing that you are not doing a typical equality test and it doesn't suffer the problems I mentioned.
As for point 2, while it is unlikely to find a compiler that have trouble guessing that the two styles mean the same thing, changing compiler is not that simple, especially if you are on an exotic platform.
I also don't believe in point 3 : whether you use it of not, "if (a = b)" remains uncommon, and it will jump at any experienced programmer.