Hello bearophile,
In a not-ranged cases body, like in the program below (that doesn't
compile), the switch variable is a compile-time constant, so why
doesn't the compile see x as constant there?
template Foo(uint x) {
static if (x <= 1)
enum Foo = 1;
else
enum Foo = x * Foo!(x - 1);
}
int bar(
Daniel Murphy:
> switch(x)
> {
> case 0:
>break; // what is x here?
> case 1:
>goto case 0:
> }
> etc
You are right. Thank you for all the answers.
Bye,
bearophile
bearophile wrote:
In a not-ranged cases body, like in the program below (that doesn't compile),
the switch variable is a compile-time constant, so why doesn't the compile see
x as constant there?
template Foo(uint x) {
static if (x <= 1)
enum Foo = 1;
else
enum Foo = x
"bearophile" wrote in message
news:ibn320$2uc...@digitalmars.com...
> In a not-ranged cases body, like in the program below (that doesn't
> compile), the switch variable is a compile-time constant, so why doesn't
> the compile see x as constant there?
In switch statements, you can do stuff lik
On 14.11.2010 1:21, bearophile wrote:
In a not-ranged cases body, like in the program below (that doesn't compile),
the switch variable is a compile-time constant, so why doesn't the compile see
x as constant there?
Well, there is fall-through ;) And there still could be goto's.
In essence "c