[DIP1005] Unused imports in with(import) declarations: leave alone of flag as errors?

Tourist via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 24 13:25:26 PST 2016


On Saturday, 24 December 2016 at 20:32:58 UTC, Andrei 
Alexandrescu wrote:
> Consider:
>
> with (import std.stdio)
> int fun(int x/*, File f*/)
> {
>     // f.writeln("In: ", x);
>     return x * x;
> }
>
> Such situations occur during refactorings and code evolution. 
> The import is no longer used. Should the compiler flag that as 
> an error, or leave it be?
>
>
> Andrei

I'd use a warning, as with unused variables: the code is in an OK 
state when in the middle of a work (such as temporarily 
commenting a block), but less OK for a release.
Also, Visual Studio highlights unused includes for C#, which is 
nice.


More information about the Digitalmars-d mailing list