[Issue 2529] 'package' access qualifier should allow access to sub-packages

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 23 18:00:21 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=2529


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-01-23 18:00:14 PST ---
(In reply to comment #3)
> IMHO, this bug should be closed as invalid, because the initial suggestion in
> the bug report is completely wrong: it would drive you to put low-level stuff
> in the root, and derived stuff in the leaves. Implementing that suggestion
> would encourage poor design. 

Agreed, applies to D2 now as well.

Also, package can actually be abused because it doesn't apply to actual
folders, it only applies to module declarations. This means you can fake your
way into getting access simply by re-creating the package folder structure and
use an import switch to introduce the new modules:

/a/m.d:
module a.m;
package void foo() { }

/a/user/a/workaround.d:
module a.workaround;
import a.m;
auto foo()
{
    return a.m.foo();  // free access!
}

/a/user/main.d:
module main;
import a.workaround;
void main()
{
    foo();
}

$ rdmd user\main.d -Iuser

No compile errors!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list