switch case for constants-only?
Rainer Deyke
rainerd at eldwood.com
Sat Dec 5 14:42:23 PST 2009
Nick Sabalausky wrote:
> As I mentioned earlier, that should be semantically equivilent to:
>
> int x = 1, y = 1;
>
> if(z == x)
> { ... }
> else if(z == y)
> { ... }
>
> In fact, it's already semantically equivilent to that, except that x and y
> are currently required to be known at compile-time.
I assume the same rule applies to 'goto case'?
int i = 0, j = 0;
switch (0) {
case i:
goto case j; // Oops, infinite loop.
case j:
// Never reached.
}
I'm basically in favor of this change - it increases the expressive
power and uniformity of the language at little cost - but corner cases
like this bother me.
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list