On 1/28/19 4:57 PM, Steven Schveighoffer wrote:
On 1/28/19 3:16 PM, H. S. Teoh wrote:
On Mon, Jan 28, 2019 at 02:54:23PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote:
On 1/28/19 11:59 AM, Victor Porton wrote:
Should I prefix all module names with `xmlboiler.` (where XML Boiler
is the name of my program). These packages are expected to be used
internally by my program, not as an exported API (however there are
some little chances that in the future I will make a public API)

I use a package nearly every time because if you don't, you run into
weird quirks of the language for top-level modules.

Really? Such as?  I've never heard of said quirks.

I'm trying to remember, but there are definitely conflicts with top-level modules that do not happen when packages are involved. Someone help me out here...

OK, so it's because top-level packages and modules imported are put into the namespace. But modules under packages are not.

So for instance, if you have:

module a;

void a() {}

----

import a;

void main()
{
   a(); // error can't call module a
}

whereas if a is changed to:

module pkg.a;

void a() {}

and the import changed to import pkg.a; then it works.

But this doesn't solve the problem of having a simple library/app with a simple module name. What do you put it under? It can't be a.a, because that doesn't help.

It really is a quirk of D that I don't like, the top level packages should not conflict with other symbols in most cases.

-Steve

Reply via email to