Private symbol (in)visibility within a module
NotYouAgain
NotYouAgain at gmail.com
Sun May 5 07:51:00 UTC 2024
On Sunday, 5 May 2024 at 07:44:25 UTC, NotYouAgain wrote:
>..
and btw. this used to be ok in D (it's not now though).
If only they fixed it so that it also applied at the level of
classes and structs, instead of stopping at the module level.
module m;
@safe:
private:
import foo;
import std;
void main()
{
Foo f = new Foo();
writeln(f.test(3)); // fine.
writeln(f.test("hi there!")); // fine.
}
/*
module foo;
@safe:
private:
public class Foo
{
private int test(int n) { return n; } // A private symbol
should not interact with other modules.
public string test(string str) { return str; } // this is
overloading a private member.
}
*/
More information about the dip.ideas
mailing list