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

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 24 16:30:01 PST 2016


On Saturday, December 24, 2016 15:32:58 Andrei Alexandrescu via Digitalmars-
d 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?

I say leave it be. It's the sort of thing that risks causing problems with
conditional compilation (not as bad as in some cases, but I still don't
think that it's worth the risk). IMHO, this is the sort of thing that should
be left up to a lint tool, and there's technically nothing wrong with it.

- Jonathan M Davis



More information about the Digitalmars-d mailing list