the point of selective importing

kris foo at bar.com
Tue Jul 11 17:06:12 PDT 2006


Jari-Matti Mäkelä wrote:
> Derek Parnell wrote:
> 
>>On Tue, 11 Jul 2006 23:20:39 +0300, Jari-Matti Mäkelä wrote:
>>
>>
>>>In my
>>>experience if your having more than 1-2 conflicting members, you're
>>>doing something wrong.
>>
>>That might be true if all the modules you use are under your direct
>>control. However, the times I've had name clashes have been due to using
>>libraries written by other people who, independently, decided to use the
>>same name. Thus in my code, I am forced to disambiguate them. 
>>
>>Consider the simple situation in Phobos
>>
>> std.string.find
>> std.regexp.find
>> internal.gc.gcx.find
>>
>>then add the various other 'find' members in external libraries.
> 
> 
> Ok, have to admit that's true. But do you really use them all in the
> same module? If there's only a small amount of conflicting names, the
> import syntax does not have to be so incredibly complex.


It can and will happen. The larger the project, the better the chance 
for conflicts. There's probably some logarithmic-style graph describing 
the relationship between the number of modules and the resulting number 
of potential conflicts. The issue does not really arise within small or 
personal projects to the same extent. Primarily because you personally 
have full control over the entire namespace.

The syntax itself does not need to be complex at all. It's downright simple:

import w.x.y.z as z;

or

import w.x.y.z : z;


Where z represents whatever you wish the required prefix to be.

No static, no alias. Looks very much like the existing import, and is 
almost as effortless to use. Perhaps you might like to read the "Import 
RFC" posted? It explains the issues in a little more depth.



More information about the Digitalmars-d mailing list