public import and bugs it causes

Steven Schveighoffer schveiguy at yahoo.com
Fri May 14 08:32:10 PDT 2010


On Fri, 14 May 2010 13:16:06 -0400, Alex Makhotin <alex at bitprox.com> wrote:

> Hello.
>
> Today I found a strange bug in my code which was caused by 'public  
> import' declaration from the wxD library.
>
> The library imports publicly the 'std.compiler' module from Phobos.
> And it has the 'const string name;' declaration.
> Some of the code of my program imported the library headers.
> None of the classes of the program have the 'name' member or any static  
> analogs. I just wanted to know why in some cases the program printed the  
> magic "Digital Mars D" words :). At that time I found the public import  
> of the 'std.compiler' module in the code of the library.
>
> Well, I'm not against the additional promotion of the Digital Mars D  
> compiler :)
>
> But, I don't want such occasions any more. Is there a solution, except  
> to avoid public imports(by the way, I avoid, it's the library code from  
> the third party)? The ideal would be a warning from the compiler, at  
> least.
> I also would like the compiler to force me to use fully qualified module  
> path to the member in the mentioned case.


name is too common an identifier.  I think std.compiler should not use it,  
it should be something like compiler_name.

FYI, this can be forced by wxD library using something like:

public import std.compiler : compiler_name = name;

-Steve


More information about the Digitalmars-d mailing list