[Issue 3819] [module system] Tiding up the imports

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 24 16:30:13 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3819



--- Comment #9 from BCS <shro8822 at vandals.uidaho.edu> 2010-02-24 16:30:08 PST ---
(In reply to comment #7)
>>I think that because it will get in the way of the programmer and
>> I expect that ,in practice, it will not solve the problem because
>> people will just use "import foo.*;" by default.
> 
> In Python that's doesn't happen, people usually import just the module name, > or some names from the module. The import all is discouraged.

I don't have any solid evidence, but I strongly suspect that the above would
not happen for D. It seems to me that the cost benefit balance falls in favor
of just importing everything. I suspect that it's similar to how in dynamic
languages there is a much stronger argument for TDD because, IIRC, python is a
dynamic language and D is not.

> And when people what to use the unqualified import syntax, adding two chars
> ".*" is not going to cost them much. 

Not my point. In fact the ease of adding it supports my point.

>>We have that right now.
> 
> We don't have it, there's a whole page about mitigating this problem:
> http://www.digitalmars.com/d/2.0/hijack.html
> And Overload Sets have being introduced as a patch on this problem.
> 

Let me be more precise: we have selective imports right now.

> 
>> If importing all names from a module imports *random* names, than
>> the problem is not the import system, but what is in the module.
> 
> By "random names" I didn't mean they are truly random, I mean that you don't
> know what you are importing.
> 

I still maintain my point, if you needs something out of a module than
importing every name in a module shouldn't import random names (using your
definition) unless the module is poorly designed.

> 
>>I'll maintain that in a well designed library, if you need one thing from a 
>> module, you will need many/most of the things in it.
> 
> In Phobos there are modules with 20-30 names of functions and other stuff. 
> User defined modules can have even more.

20-30 names? Is it that low? I thought you were talking about hundreds of
names. Now I'm not even sure why you are bothering.

> D is not Java, you are supposed to 
> put related classes inside a single module. So about 100% of the times I 
> don't use all things that are present in those modules.

Most of the time using Phobos, I want to have most of or none of a module
available (even if I don't use some of it).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list