On Monday, 8 June 2020 at 16:02:02 UTC, Steven Schveighoffer wrote:
On 6/8/20 11:11 AM, jmh530 wrote:
On Monday, 8 June 2020 at 14:27:26 UTC, data pulverizer wrote:
[snip]

Out of curiosity what does the "." in front of `foo` mean? [snip]

ag0aep6g provided the link to it [snip]

The dot operator simply specifies that the symbol you are looking for is defined at global scope, so it just changes the lookup rules.

Even though it makes the code clearer what foo you are looking at, it was not necessary -- removing the dot works.

In some cases it is necessary to use the . lookup rule, because you have another symbol that will be picked first.

For example:

int x;

template bar(string x)
{
   mixin("alias " ~ x ~ " = .x;");
}

-Steve

Thanks both of you. It's one of those puzzling things that was at the back of mind that has just been resolved.

Reply via email to