I am addicted to "braceless" ifs, like this:
if (a) b++, c++, d = e;
But one annoying thing is that return cannot be a part of the last part. Intuitively I feel why is that, but can anyone explain in programming language terms why this will not compile?
main() {
int a, b, c, d, e;
if (a) b = c, d = e, return;
}
If you care, please also explain why is that designed like that, it seems like a flaw to me. I can understand in C but in C++ it could have been redesigned without major compatibility loss with the existing C code.
Just for comparison: these will compile and do exactly what expected:
while (a < 10) a++, b--, c += 2;
while (a < 10) if (a == 5) half = a, save();