importing modules with non-identifier names

Justin Johansson no at spam.com
Sat Nov 21 15:08:36 PST 2009


Andrei Alexandrescu Wrote:

> Has anyone been irked by this? If you have a module called 5th-element.d 
> there is no way to import that. I don't think it's a major issue, but 
> I'm also seeing it as a limitation that should have a better explanation.
> 
> One way to circumvent that may be
> 
> import fifth = "5th-element.d";
> 
> i.e., specify the file as a string and assign to it a regular D 
> identifier. Probably similar things have been discussed in the past, 
> what's the general impression?
> 
> 
> Andrei

I'm irked that it seems like you cannot use keywords as module names.

Say if one were writing a compiler for the next big language in D, then it would be reasonable to expect that you could have a D source file called scope.d, module.d etc.

Unfortunately as a consequence of this you cannot write (with DMD 1 compiler at least)

import nextBigLanguage.scope;
import nextBigLanguage.module;

Maybe there is some work-around but, even if there is a work-around, for something like this, it is not nice.

-- Justin Johansson




More information about the Digitalmars-d mailing list