A suggestion for modules names / sharing code between projects

Sebastien Alaiwan via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 1 22:40:53 PST 2016


On Wednesday, 2 March 2016 at 00:16:57 UTC, Guillaume Piolat 
wrote:
> Would this work?
>
> 1. pick a single module name like
>
>     module math.optimize;
>
> 2. import that module with:
>
>     import math.optimize;
>
> 3. put this module in a hierarchy like that:
>
>     math/optimize.d
>
> 4. pass -I<directory-containing-math-directory> to the compiler
>
> However it may clutter your module namespace a bit more.

Yeah, this is what I going to do: flat hierarchy, like one 'src' 
directory and one 'extra' directory in the project root, globally 
unique package names, passing -Isrc and -Iextra to the compiler, 
and ... module declaration directives.
I was trying to avoid them, but maybe it's not possible.

I still think that software entities shouldn't depend upon their 
own name, or their absolute location in the top-level namespace.

This is true for classes, functions/methods, variables, 
structures ... maybe this rule becomes invalid when third-party 
packages enter a project?



More information about the Digitalmars-d mailing list