Warn on unused imports?

JN 666total at wp.pl
Fri Oct 5 12:15:47 UTC 2018


On Wednesday, 3 October 2018 at 17:33:43 UTC, Dennis wrote:
> 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
>
This is a big point actually. There are several design choices in 
D that were made for the ease of parsability of the code, for 
example using !() instead of <> (personally I think <> look much 
cleaner, but I understand how it's harder to parse).


As for the thread. I think this could work either as a warning or 
in the compiler. The problem with making it a warning is that 
people might want to disable the feature once it breaks the 
build. It's a big pain in Go. Imagine importing a logger, and 
then putting some log methods int he code. Everything is fine. 
Then you comment out the log lines just for a moment, and bam, 
import logger is unnecessary and your build breaks.


More information about the Digitalmars-d mailing list