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

Bill Baxter wbaxter at gmail.com
Fri Nov 13 11:55:23 PST 2009


On Fri, Nov 13, 2009 at 11:36 AM, Clay Smith <clay.smith.r at gmail.com> wrote:
> Bill Baxter wrote:
>>
>> On Fri, Nov 13, 2009 at 11:15 AM, Clay Smith <clay.smith.r at gmail.com>
>> wrote:
>>>
>>> bearophile wrote:
>>>>
>>>> Clay Smith:
>>>>
>>>>> I would like my all.d files to not give errors :o<
>>>>
>>>> "all.d" files are a hack used to patch one of the minor holes of the
>>>> current D module system. The right way to do that is with a syntax like
>>>> (that must not import the 'foo' name too in the current namespace, only
>>>> the
>>>> names inside "std.foo"):
>>>>
>>>> import std.foo: *;
>>>>
>>>> Every part of a language needs to be designed with care. Approximate
>>>> designs with several holes aren't enough.
>>>>
>>>> Bye,
>>>> bearophile
>>>
>>> That would be a nice feature.
>>
>> It would be a convenient feature, but in both Java and Python where
>> they have this feature, its use is frowned upon.
>>
>> --bb
>
> I don't understand why its frowned upon, if you really want to see what you
> are importing then look at the folder where the import is coming from.

Here's what I could dig up:
http://www.omahapython.org/IdiomaticPython.html#importing

The more unnecessary stuff you have in your namespace the harder it is
for people to figure out what your code is doing.

Also using "import foo.*" means that the addition of a file could
cause your program to stop compiling since a previously unambiguous
symbol becomes ambiguous.

But I guess it remains even in Python 3 because it's quite handy for
writing small scripts.

--bb



More information about the Digitalmars-d mailing list