switch case for constants-only?
Don
nospam at nospam.com
Sat Dec 5 13:16:18 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.
Switch with constant values is completely different to a switch
statement with variables -- it's reasonable to expect O(1) case
comparisons if all the values are known at compile time, but I think
that's impossible with variable cases.
Allowing switch with variable cases at the expense of constant cases
would be a real PITA for non-dynamic code. You'd need some way of
handling both.
More information about the Digitalmars-d
mailing list