public import and bugs it causes
Alex Makhotin
alex at bitprox.com
Fri May 14 16:36:39 PDT 2010
Walter Bright wrote:
> I don't agree that it's a hole or a bug.
I disagree.
> The designer of an imported
> module has complete control over what names will be visible to the
> importer and which aren't. This is as it should be.
I don't want to deal with the bad design of someone's module.
For example.
> module Server.TestM2;
> const string name = "New Name";
> module Server.TestM1;
> public import Server.TestM2;
> module Server.Main;
> private import Server.TestM1;
In the scope of Server.Main module the global variable 'name' is visible.
That should not be so. The Server.Main module should explicitly import
module Server.TestM2 to be able to use of variable 'name'.
It's much better to make restriction in the language specification to
eliminate misuse.
The use of globals is error prone. I consider it a bad practice.
In the extreme case I would like to see D's specification restricting
globals as C# does.
--
Alex Makhotin,
the founder of BITPROX,
http://bitprox.com
More information about the Digitalmars-d
mailing list