On Monday, March 11, 2013 20:14:07 Timon Gehr wrote: > Actually, in D, static if creates its own scopes for declarations made > inside the static if condition.
No, it doesn't, and it would be _way_ less useful if it did, particularly with regards to struct and class definitions. Take this code, for instance, import std.stdio; static if(true) int var = 7; else string var = 12; void main() { int i = var; static if(is(typeof(var) == int)) int j = 22; else float j; writeln(j); } It compiles just fine and prints 22. Both the static if at module-level and the one in the function declare variables which are used outside of the static if blocks. static if does _not_ create a new scope. And putting braces around the static if bodies has no effect on the scoping either. - Jonathan M Davis