Point before the template
Adam D. Ruppe
destructionator at gmail.com
Tue Jul 16 14:07:30 PDT 2013
On Tuesday, 16 July 2013 at 21:03:07 UTC, cmplx wrote:
> But I was wrong when I tried this example and put point before
> the factorial. But it still worked. why?
In D, .name means "look up name in the global scope". Since
factorial is in the global scope, it found it successfully and
everything worked.
The place this would be useful is something like this:
int a = 10;
void foo() {
int a = 20;
writeln(a); // 20
writeln(.a); // 10 - the dot tells it to use the global
instead of the local
}
More information about the Digitalmars-d
mailing list