[Issue 2028] Can't create template class in module of same name

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 24 16:23:57 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2028





------- Comment #3 from wbaxter at gmail.com  2008-04-24 18:23 -------
(In reply to comment #2)
> (In reply to comment #1)
> > I don't know whether to call this a bug or a language design issue, but I know
> > the workaround: specify the full name
> > 
> > Use
> >     a.a
> > instead of
> >     a
> > 
> 
> I think this can also be avoided by having the module in a package.  Then DMD
> seems not to get confused.  I've not totally understood the specifics, it seems
> modules and other symbols conflict in ways that package names don't.
> 
> So I think if you put a.d into an 'a' directory, make it's module statement be
> "module a.a;" then do 
> 
> import a.a;
> 
> then you won't get the conflict.  Can anyone confirm this?  Don't have time at
> the moment...
> 

Jarrett Billingsley wrote:
>That wouldn't work either, since the top-level name is also a.  It's that 
modules and packages have a higher precedence than the symbols within them. 

Ah, ok.  So I guess when I've gotten rid of such problems in the past by
putting the offending module in a package, it worked because I named the
package something that didn't conflict.

But this still does point out the issue with namespace pollution that arises
when using top-level, no-package modules.  Seems like that should be a general
rule of thumb for D programming -- "Effective D": Rule #1: always put your
classes in a package.


-- 



More information about the Digitalmars-d-bugs mailing list