Point before the template

cmplx magiisto at mail.ru
Tue Jul 16 15:12:32 PDT 2013


On Tuesday, 16 July 2013 at 21:07:31 UTC, Adam D. Ruppe wrote:
> 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
> }

Compile error:
Error: undefined identifier 'a'


More information about the Digitalmars-d mailing list