public aliases to private/package symbols
Martin Nowak
dawg at dawgfoto.de
Thu Jan 26 09:32:57 PST 2012
> The issue is not with aliases, accessability already has a natural grey
> area:
>
> ====================
> module lib;
>
> private struct Foo {}
>
> // Should any of these be allowed?
> public Foo getFoo() { return Foo(); }
> public void takeFoo(Foo f) {}
> struct Bar
> {
> Foo f;
> }
>
> ------
>
> module main;
> import lib;
>
> getFoo(); // Allowed?
>
> takeFoo(getFoo()); // Allowed?
>
> Bar b; // Allowed?
>
> takeFoo(b.f); // Allowed?
>
> b.f = getFoo(); // Allowed?
>
> // Allowed? If so, can you *do* anything with x?
> auto x = getFoo();
>
> ====================
>
The solution seems to be to check protection only during symbol lookup.
Thus all of the above are allowed and you can do with x what Foo allows
you to
(aggregates default to public protection).
More information about the Digitalmars-d
mailing list