Keeping imports clean

James Miller james at aatch.net
Sun Apr 1 15:29:56 PDT 2012


On 2 April 2012 10:12, Guillaume Chatelet <chatelet.guillaume at gmail.com> wrote:
> In C++ it clearly matters to have very clean dependencies to keep
> compilation time as low as possible ( Google even built a tool to check
> unused #include - http://code.google.com/p/include-what-you-use ).
>
> So I was telling to myself it would be great to have the D compiler report
> about unused import because it might already have all the necessary
> information. But maybe such a tool already exists ? Or maybe this is simply
> irrelevant ?

D doesn't have includes, importing a module that you don't use doesn't
matter because D only needs the imports to find function declarations.
This is clear in the import syntax:

    import std.random : uniform //import only uniform from the std.random module

so it is a symbolic import, not a textual import. Also note that while
D has .di ("D Interface") files, they are not required, and often
people don't even bother with them, merely distributing the source.

So in short, it isn't relevant at all, since there is no preprocessor
to f**k things up.

--
James Miller


More information about the Digitalmars-d mailing list