How about Go's... error on unused imports?

Nick Sabalausky a at a.a
Mon Nov 16 13:22:18 PST 2009


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:hdr7mp$1ei2$1 at digitalmars.com...
> Leandro Lucarella wrote:
>> Walter Bright, el 12 de noviembre a las 19:35 me escribiste:
>>> Andrei Alexandrescu wrote:
>>>> I think this is an environment issue. I like Eclipse's approach.
>>>> Java unnecessary imports are underlined with a wavy red line.
>>> I agree. I would find it very annoying to have to remove unused
>>> imports to get it to compiler. First off, I tend to have "all"
>>> imports that import everything.
>>
>> That's odd, first you say you think D would be a failure if it needs an
>> IDE and now you say that the only way to avoid unnecessary dependencies
>> you should rely on an IDE =)
>
> It's not a problem that needs fixing. It's not a bug, it's a stylistic 
> issue. IDEs are good for that.
>
>
>> I really think this should be a compiler feature. Make it a warning then
>> (and while you are at it, make it a *real* warning, not a warning-error).
>>
>>> Secondly, what if I version out some code, wouldn't want to version the
>>> import too.
>>
>> Why?
>
> Because I often block out and unblock out code during development. Having 
> to go up and dink with the imports too would be quite annoying.
>
> At some point, adding too much of this nagging stuff into a language will 
> drive people away.

The is why the general consensus in the thread is that it should be an 
optional notice by the compiler rather than an error.

So you don't want to have to remove unused imports to get something to 
compile? Great. I fully agree. So how about having it as an optional 
diagnostic (as almost everyone on this thread has suggested)? It's pretty 
hard to imagine that causing anyone any trouble.





More information about the Digitalmars-d mailing list