public import and bugs it causes
Alex Makhotin
alex at bitprox.com
Fri May 14 16:04:03 PDT 2010
I think this is a bad design of the language.
Global variables are bad things.
C# doesn't have them.
In this sense I like C# which prohibits any fields or methods in namespaces.
And few words considering public imports in D.
Excerpt from the C# 4.0 language specification
(http://www.microsoft.com/downloads/details.aspx?FamilyID=dfbf523c-f98c-4804-afbd-459e846b268e&displaylang=en#filelist)
says:
> A using-namespace-directive imports the types contained in the given namespace, but specifically does not import nested namespaces. In the example
> namespace N1.N2
> {
> class A {}
> }
> namespace N3
> {
> using N1;
> class B: N2.A {} // Error, N2 unknown
> }
> the using-namespace-directive imports the types contained in N1, but not the namespaces nested in N1. Thus, the reference to N2.A in the declaration of B results in a compile-time error because no members named N2 are in scope.
In D I can achieve similar(?) behavior by using 'import'('private
import' by default). But I also can evade by using explicit 'public
import'. This leads to bugs.
Globals lead to bugs.
--
Alex Makhotin,
the founder of BITPROX,
http://bitprox.com
More information about the Digitalmars-d
mailing list