Example of recursive templates in http://dlang.org/template-comparison.html

template factorial(int n) {
       const factorial = n * factorial!(n-1);
 }
template factorial(int n : 1) {
         const factorial = 1;
 }

void test() {
        writefln("%d", factorial!(4)); // prints 24
}

But I was wrong when I tried this example and put point before the factorial. But it still worked. why?

template factorial(int n) {
       const factorial = n * .factorial!(n-1);//<------
 }
template factorial(int n : 1) {
         const factorial = 1;
 }
void test() {
        writefln("%d", factorial!(4)); // prints 24
}

I`m using DMD 2.063

Reply via email to