public import and bugs it causes

bearophile bearophileHUGS at
Fri May 14 13:23:13 PDT 2010

Nick Sabalausky:
> In Java circles, and probably some others too, "import foo.*;" is widely 
> considered bad practice.

I know this problem in Python and I know about a similar (but not equal, because Java is statically typed) problem in Java. But I think you have not grasped the whole D module situation yet.

In a system lot of complexity comes from interactions between its subsystems. If some of such interactions are unwanted the system behaviour can become unpredictable. The subsystems in a D program are its modules. The purpose of a well designed module system is to remove a source of unwanted complexity, it must remove unwanted interactions between modules. Explicit is better than implicit. You want to explicitly state what interactions you want. Sometimes static imports can be useful, but they are the antitheses of a module system (just as casts are ways to punch holes in a type system).


More information about the Digitalmars-d mailing list