On 27.02.2012 07:15, Nevin Liber wrote:
When you specify what you mean by "not checked by the compiler", then we'll talk. :-) Until you do, it is trivial to poke holes in it. For instance:
if (0) { Fire Fire Fire! (note: this line is NOT a C++ comment) if (ShouldTheIf0OnlyGoToTheFirstEndBraceItFinds()) { } LaunchTheMissiles(); if (0) { }
Did you really mean to launch the missiles?
That's not Robert's obligation to answer, since the original static if proposal leaves the details of this question open as well. (Note, though, that Andrei said that at the very least, the parser would have to ensure that the tokens are brace-balanced in the dead branch. There is no sane way to parse the example you've just given.) Robert's suggestion is just that "static if" can be replaced by "if" if the compiler is simply required to act as if the "if" was a "static if" if the condition is a constant expression. I think this is feasible. I also think it obscures intent, which is why I'm against it. Sebastian