Module self-imports

Dmitry Olshansky dmitry.olsh at gmail.com
Fri Oct 5 02:03:05 PDT 2012


On 05-Oct-12 07:43, Andrej Mitrovic wrote:
> 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).

Haven't thought of that.

> 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 suspect that we can't break code. So the only thing I'd want now is 
for these statements to *truly* have no effect.
It seemed to have some ;)

> 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
>


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list