Need review: explicit package protection

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 10 04:48:17 PDT 2014


On Monday, 9 June 2014 at 13:51:30 UTC, Dejan Lekic wrote:
> However, package module still have few issues.
>
> Issue #1)
>
> Few times I asked myself "what am i importing, package or a
> module?" when I used package module, so whenever I import a
> package, I add a short comment, something like:
>
> // assuming I have
> import foo.bar.baz; // package import

Why is this important? `package.d` is intentionally designed so 
that package imports are indistinguishable from module imports. 
That way library author can adjust module structure without 
breaking user code.

> Issue #2)
> Package module is not possible in projects with flat structure
> (projects whose authors did not reserve directories for 
> packages.
>
> Example:
> Imagine developer has *all* his D sources in
> /home/dejan/src/d/myawesomeproject because he does not like big
> directory structures. Say his project has two packages foo.bar
> and foo.baz . And has following files in his project directory:
>
> tools.d // module foo.bar.tools;
> control.d // module foo.bar.control;
> screen.d // module foo.baz.screen;
> window.d // module foo.baz.window;
> package.d // can be only one 'package.d' within a single
> directory!
> main.d
>
> ...

I'd call this "INVALID WON"T FIX" :) D module system is defined 
to have strong 1-to-1 matching with file system. Any attempt to 
circumvent that in favor of personal preferences is asking for 
trouble and is not worth supporting.



More information about the Digitalmars-d mailing list