Updated DIP22 - Private symbol visibility

Martin Nowak code at dawg.eu
Sat Dec 21 14:56:10 PST 2013


On 12/21/2013 11:17 PM, Timon Gehr wrote:
> 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
> }
This will work.

> module b;
> import a;
>
> void y(){
>      call!foo(); // _same_ symbol as in module 'a'.
> }
This would say, Error: overload auto a.foo(int) is not accessible from 
module b.


More information about the Digitalmars-d mailing list