A suggestion for modules names / sharing code between projects
Sebastien Alaiwan via Digitalmars-d
digitalmars-d at puremagic.com
Mon Feb 29 13:04:52 PST 2016
On Monday, 29 February 2016 at 20:59:45 UTC, Adam D. Ruppe wrote:
> On Monday, 29 February 2016 at 20:05:11 UTC, Sebastien Alaiwan
> wrote:
>> Although, I'm trying to avoid having these redundant module
>> declaration directives at the beginning of each of my library
>> files.
>
> Those module declarations aren't redundant - they are virtually
> required (I think it is a mistake that they aren't explicitly
> required in all cases, actually)
>
> The file layout does not matter to the language itself. Only
> that module declaration does - it is NOT optional if you want a
> package name.
$ find
main.d
foo/hello.d
$ cat main.d
import foo.hello;
$ cat foo/hello.d
module foo.hello;
Ok so now let's say I rename the directory "lib" to "foo". If I
don't change the "import lib.hello" to "import foo.hello", how is
the compiler going to find "hello.d"?
(As a reminder, as I said, I'm using separate compilation)
More information about the Digitalmars-d
mailing list