public import and bugs it causes

Simen kjaeraas simen.kjaras at
Sat May 15 03:09:48 PDT 2010

Alex Makhotin <alex at> wrote:

> bearophile wrote:
>> Note that D module system is not modelled on C#.
> I think that to become successful competitor for such languages as C#,  
> the D language requires improvement.
> In the bug I encountered, I mistyped the variable and it *matched the  
> global variable accidentally*. I was unaware of it because the compiler  
> was silent, but IMHO it, at least, should give me a warning.
> It's not possible in C#. That's what I meant.


module a;

class foo {
module b;

import a;

class fool {

void bar( ) {
     auto f = new foo( ); // Oh noes, I meant fool, not foo!

As you can see, this is perfectly possible with things other than global
variables. One could even imagine mistyping a module name and still getting
a program that compiles. Now how does C# make that impossible?


More information about the Digitalmars-d mailing list