A suggestion for modules names / sharing code between projects
Sebastien Alaiwan via Digitalmars-d
digitalmars-d at puremagic.com
Mon Feb 29 12:05:11 PST 2016
On Monday, 29 February 2016 at 19:56:20 UTC, Jesse Phillips wrote:
> I've used this pattern.
>
> ./projectA/lib/math/algo.d
> ./projectA/lib/math/lcp.d
> ./projectA/lib/math/optimize.d
> ./projectA/gui/main.d
>
> ./projectB/app/render/gfx.d
> ./projectB/app/render/algo.d
> ./projectB/lib/math/algo.d
> ./projectB/lib/math/lcp.d
> ./projectB/lib/math/optimize.d
> ./projectB/main.d
>
> Dub doesn't like me too much, but in general it works.
>
> Note that it doesn't matter where your modules live, if they
> have the declared module name in the file:
>
> module math.optimize;
>
> If DMD reads this file all your imports should look like:
>
> import math.optimize;
>
> Even if the file is in app/physics/math.
Yeah, I'm using this pattern too at the moment ;
Although, I'm trying to avoid having these redundant module
declaration directives at the beginning of each of my library
files.
More information about the Digitalmars-d
mailing list