Warn on unused imports?

Dennis dkorpel at gmail.com
Wed Oct 3 17:33:43 UTC 2018


On Wednesday, 3 October 2018 at 14:27:42 UTC, Dejan Lekic wrote:
> IDK, I prefer things done in the UNIX way - do one thing and do 
> it right. Compiler should do what its name says - COMPILE, 
> while some other tool should be made for these kind of code 
> checks. The code will compile no matter whether there are some 
> unused imports or not, right?

Sure, the Unix way is a nice philosophy, but let's face the facts:
- Because of (amongst others) CTFE and mixin, D is an incredibly 
complicated language to reason about (unlike Java or C#)
- There is only one D front-end, and it will likely stay that way 
for a while
- Any static analysis tool that doesn't only work with a subset 
of the language must basically re-implement a complete compiler 
front-end or leverage dmd

Also dmd is currently not following the Unix way by a long shot. 
You could have separate programs for the optimizer and assembler, 
like some compilers have. Every stage of compilation could be a 
separate program, and that would even be beneficial to static 
analysis tools, but that has other problems too (like changes in 
the API, worse performance because of text input and output).

Currently we have a package that does everything that requires 
intricate knowledge of the D language: compiling, documentation 
generation, profiling, and warning about things like dead code. 
Also unit-testing is part of the language and the standard 
library is huge. Warning about unused imports seems like a useful 
addition to me.


More information about the Digitalmars-d mailing list