visibility of private Class C in module named "C"; private variables in modules
kdevel
kdevel at vogtner.de
Sat Dec 26 15:58:30 UTC 2020
~~~Private.d
module Private;
class A {}
private class B {}
package class Private {
void foo () { __PRETTY_FUNCTION__.writeln; }
}
~~~
~~~main.d
void main ()
{
import Private: A; // okay
// import Private: B; // main.d(4): Error: module Private
member B
// is not visible from module main
// okay
// import Private: Private; // main.d(8): Error: module Private
member
// Private is not visible from module
main
// oh-kay, but
import Private;
auto p = new Private; // works, but Private.Private is private
?!?
p.foo;
}
~~~
I don't get it. Furthermore according to
https://wiki.dlang.org/Access_specifiers_and_visibility#private
there is always external linkage on private variables and
functions.
Does D not provide a means to stop symbols from going into the
object file?
More information about the Digitalmars-d-learn
mailing list