package modules and how to generate a shared library plus .di file (I)
Neia Neutuladh
neia at ikeran.org
Thu Dec 7 17:36:22 UTC 2017
On Thursday, 7 December 2017 at 16:39:14 UTC, kdevel wrote:
> But why do I have to use the prefix "mymod.:" in the
> library case?
If you have an editor open with ten tabs pointing to different
files in your source tree, all your imports are uniform -- you
don't have to step back and consider where the specific file
you're editing is and calculate relative import paths.
You always import a given module with the exact same code. If you
copy and paste code between two modules and that contains an
import statement, it just works.
If you decide to move a module to a different package, you need
to change its module name, move it on disk, and update the stuff
that imports it. You don't have to update every import it does.
If you have a source tree like:
pierce/
db/
core.d
controllers/
feed.d
then feed.d can have `import pierce.db.core;` instead of people
being confused about how to refer to the parent directory in a
relative imports style.
The tradeoff is that you have to type sometimes as many as twelve
extra characters in a handful of lines of code.
More information about the Digitalmars-d-learn
mailing list