Module self-imports

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Oct 4 20:43:39 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8447

There's a bunch of self-imports (only a few) in Phobos, they're
usually in unittest blocks. I'm thinking this was put there for
convenience (so you can copy the snippet into a different module and
get an import statement for free).

Question: Should self-imports be banned? And if so, should they be
completely banned or only banned in module scope (allow them in
function/unittest blocks)?

I have a gut feeling that many people inadvertently (or on purpose)
have self-imports in their projects, and if this was banned there
might be a lot of projects that stopped compiling.

*Note*: I'm talking about direct self-imports, meaning A->A, not A->B->A:

module foo.bar;
import foo.bar;  // would be an error


More information about the Digitalmars-d mailing list