On Wednesday, 26 October 2016 at 04:51:23 UTC, Jason C. Wells wrote:
I am reading through Ketmar's iv.d/nanovg/package.d:

  module iv.nanovg;
  public import iv.nanovg.nanovg;

This looks like three levels of hierarchy, but is it?

it maps to "iv/nanovg/nanovg.d" according to dmd map rules. i used to have all the code in package.d, but later moved it out to nanovg.d.

i.e. last name is always a file, everything before it is a directory.

I'm a little confused because the corresponding directory in ketmar's source code is named "iv.d" rather than "iv" which is what I would have thought to find based on the import.

this is a repository name. it is supposed to be named just "iv", and git names main directory by repository name if you are doing a simple clone. my bad, i should have made that clear.

I see mention of a subpackage in my previous thread. Is this how a subpackage is implemented?

actually, packages and subpackages are just a convenient terms for something that is not strictly defined in D. this is more a convention: if we'll place all the files in directory, say, "mypkg/a.d", "mypkg/b.d", and add package.d there as "mypkg/package.d", then we'll be able to just write "import mypkg;". dmd will automatically look for "mypkg/package.d" in this case.

so, when you're writing "import iv.nanovg;", dmd looks for "iv/nanovg/package.d", and process it. package.d does more imports, so dmd loads 'em too. the only magic here is special "package.d" file.

Reply via email to