Keyword "package" prevents from importing a package module "package.d"

Paul Backus snarwin at gmail.com
Thu Nov 2 18:08:09 UTC 2023


On Thursday, 2 November 2023 at 12:52:35 UTC, BoQsc wrote:
> Therefore the need to import `package.d` is needed and I can't 
> see a solution, which means
>  that D Language might have to introduce a way to import 
> `package.d` from inside the package, if there is a need to 
> further improve experience of having a self-testing packages in 
> both `dub` and `package modules`.

It's perfectly legal to write `import packagename;` in a file 
that's inside the `packagename/` directory. You just have to make 
sure that *the current directory in your terminal window* is 
outside the `packagename/` directory when you run the compiler.

The D compiler *always* looks up files *relative to your 
terminal's current directory*. It does not care at all where the 
files are relative to each other.


More information about the Digitalmars-d-learn mailing list