Updated DIP22 - Private symbol visibility

Timon Gehr timon.gehr at gmx.ch
Sat Dec 21 14:17:05 PST 2013


On 12/21/2013 11:03 PM, Martin Nowak wrote:
> On 12/21/2013 10:28 PM, Timon Gehr wrote:
>> Well, you pass an alias. Are you saying that for alias template
>> arguments, the scope of the template declaration applies for
>> accessibility checking? I.e. we cannot pass private symbols as alias
>> arguments? I think this is an unreasonably high price to pay.
>>
> You can pass them and basically it behaves like public aliases, in the
> sense that the one who instantiates a template passes a public alias to
> a possibly private symbol.
> ...

I see. Then how are you going to handle the following:

module a;

private auto foo(int x){ }
auto foo(double x){ }

auto call(alias a){ a(0); }

void x(){
     call!foo(); // ok
}

module b;
import a;

void y(){
     call!foo(); // _same_ symbol as in module 'a'.
}


> It's a question of transitivity what the template can do with the symbol.
>
> Currently it's not possible to call private functions or private methods
> of variables that are passed via alias parameter.
> ...

That's probably fine. (It is certainly nothing to touch while fixing the 
private symbol clash issue.)



More information about the Digitalmars-d mailing list