Namespace for a module defined by its import path

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 24 17:42:59 PDT 2016


On Monday, 24 October 2016 at 21:06:18 UTC, Jeff Thompson wrote:
> Basically, I want the namespace of the identifiers in the 
> library module to be defined by the path which is use to load 
> them *without needing to put the path in the module file.*  Is 
> there some way to do this?

That's not going to work... but why do you want this? If they are 
different versions of the file, editing the module definition 
should be no real problem. You can use renamed imports or a 
helper module with public import to keep user code more 
compatible.

You can also do the opposite easily: have several files all with 
the same module name, but pick the specific path you want on the 
command line. Just make two files, v1.d and v2.d, both with 
`module myproject.myfile;` and import it as `import 
myproject.myfile;`

When compiling, then just do `dmd yourcode.d v1.d` or `dmd 
yourcode.d v2.d` to pick the one you want.




More information about the Digitalmars-d mailing list