Best practice for dub registry package and module names
Adam D Ruppe
destructionator at gmail.com
Sun Sep 4 12:09:51 UTC 2022
On Sunday, 4 September 2022 at 03:50:56 UTC, Ali Çehreli wrote:
> For example, there is fixedsizearray, which does not belong to
> any package:
Yeah, this is bad design since two separate people might reuse
the name and then end users - even if it comes through a couple
layers of dependencies they didn't even know about - can see
conflicts when they try to link the program.
You really need globally unique D names.
> On the other hand, arsd-official:minigui does have a package.
> (And that answers a question: Dash character is acceptable in
> package and module names.)
dub allows dash. D does not. The dub name and the D name do not
have to match (I personally consider this yet another design flaw
in dub, but it is what it is).
The reason mine is called "arsd-official" on dub is because
someone else registered "arsd" before me, but they didn't keep up
with changes, so I had to do it myself but the name was already
taken.
But remember, the dub package name and the D package/module names
are completely separate. D knows absolutely nothing about dub and
dub knows very little about D. You should have them match when
you can for user convenience, but it doesn't actually check it.
> How does that work? When the following dependency added to a
> user's project,
>
> "arsd-official:minigui": "~>10.9.1"
>
> does dub pull the entirety of arsd-official and then use
> minigui module from it?
Yes, dub always pulls its top level thing in full. Then I had to
specify a long list of subpackages in dub.json to let it
understand the independent modules.
Dub is unbelievably and embarrassingly bad. It really is a
disappointment, but you can make it somewhat work if you repeat
yourself enough times. Downloading a few extra kilobytes of D
code is the least of its problems.
More information about the Digitalmars-d-learn
mailing list