Learning D - modules packages and the package.d

Ali fakeemail at example.com
Wed Apr 4 04:54:50 UTC 2018


I am going through the Learning D book by Michael Parker
So every now and then I will make post about the book
either critics of the book, book content or questions


First critic
chapter 2 - the special package module

this small section, suggest an idiom to create a package which 
can have any name
the book suggest somepack
and inside it add a module package.d , so you will end up 
somepack/package.d
inside the file add

> module somepack; //notice this named after the folder
> //then public import std.stdio, somepack.one, somepack.two; 
> //etc

at first i though package.d is special name, as in i must call 
the file package.d or this trick or idiom to work
also it felt weird that the module name, is named after the 
folder name, which previously was referred to as the package name

anyway, i started playing with this, and renaming everything
and my conclusion is

i not really sure, if D really support or have packages
as in D is aware that some modules are together in a package

it seems to me at this time D only support modules
modules can have names with . in them
you can use the . in module names to make it seem as if its 
packages

> import io = long.module.name

also seem as a trick that complements having modules with long 
names with dots in them

and it seems you really need to match file and module names

my critic of the chapter 2 so far, the book doesn't really help 
clarify this situation
i am relieved though to learn that D doesnt treat special 
file/module names as special


More information about the Digitalmars-d-learn mailing list