Namespace for a module defined by its import path
bitwise via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 24 16:26:09 PDT 2016
On Monday, 24 October 2016 at 21:06:18 UTC, Jeff Thompson wrote:
> I have different versions of a library module in different
> folders. For example
>
> /version1/lib.d
> /version2/lib.d
>
> In my application I need to be able to update the names of the
> different folders without needing to change the module files.
> That means the file cannot contain "module version1.lib;" since
> I may need to change it to "versionA".
>
> Ideally, I want to omit the "module" declaration in the library
> file, but still import it with the desired file path as "import
> version1.lib;". And I would also want to "import
> version2.lib;" without conflict.
>
> 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?
Not sure if I understand you correctly, but you're allowed to
omit the module declaration, if that helps:
https://dlang.org/spec/module.html#module_declaration
"The ModuleDeclaration sets the name of the module and what
package it belongs to. If absent, the module name is taken to be
the same name (stripped of path and extension) of the source file
name."
More information about the Digitalmars-d
mailing list