Module self-imports

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Oct 5 04:34:16 PDT 2012


On 10/4/12 11:43 PM, 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).
>
> 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

Interesting. I don't see what bugs or inefficiencies that might cause, 
so I'd say by the TAWD (Turtles All the Way Down) principle we should 
allow them as a no-op.

Andrei


More information about the Digitalmars-d mailing list