Point before the template
cmplx
magiisto at mail.ru
Tue Jul 16 14:03:05 PDT 2013
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
More information about the Digitalmars-d
mailing list