switch case for constants-only?

Sean Kelly sean at invisibleduck.org
Sat Dec 5 14:08:10 PST 2009


Nick Sabalausky Wrote:

> I just noticed in D1 that the values for the cases in a switch must be known 
> at compile-time (btw, the docs don't seem somewhat vague on that). Is this 
> also true in D2? If so, I don't suppose we could get that changed before the 
> book? It's a real PITA for dynamic code. 

int x = 1, y = 1;

switch( z )
{
case x:
    ...
case y:
    ...
}

What should this do?  Throw an exception perhaps?



More information about the Digitalmars-d mailing list