visibility of private Class C in module named "C"; private variables in modules

kdevel kdevel at vogtner.de
Sat Dec 26 18:43:19 UTC 2020


On Saturday, 26 December 2020 at 17:48:17 UTC, Mike Parker wrote:
> On Saturday, 26 December 2020 at 15:58:30 UTC, kdevel wrote:
>
>> package class Private {
>>    void foo () { __PRETTY_FUNCTION__.writeln; }
>> }
>
>>
>>    import Private;
>>    auto p = new Private; // works, but Private.Private is 
>> private ?!?
>
> You've declared `Private` as `package`.

Hit but not sunk. It makes no difference:

~~~Private.d
module Private;
import std.stdio: writeln;

class A {}
private class B {}
private class Private {
    void foo () { __PRETTY_FUNCTION__.writeln; }
}
~~~

$ dmd main.d
$ ./main
void Private.Private.foo()



More information about the Digitalmars-d-learn mailing list