Wed, 18 Nov 2009 03:10:57 -0800, Bill Baxter wrote:

> Didn't this used to work?
> 
> template factorial(int i) {
>     enum factorial = (i==0) ? 1 : i*factorial!(i-1);
> }
> 
> With DMD 2.036 I'm getting:
>   Error: template instance factorial!(-495) recursive expansion
> 
> Seems like it expands both branches regardless of the condition. And
> seems to me like it shouldn't.

There's probably a confusion here. It evaluates lazily the value of 
factorial!(), but its type (which happens to be infinitely recursive must 
be evaluated eagerly in order to infer the type of the ternary op.

Reply via email to