importing modules with non-identifier names

Yigal Chripun yigal100 at gmail.com
Sat Oct 31 13:27:00 PDT 2009


On 31/10/2009 20:58, Don wrote:
> 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?
>
> It's just one of a great many cases which would be fixed by introducing
> __identifier("XXX"). (That's also a construct which would do wonders for
> string mixins, BTW).

This could be done by adding a Symbol type a-la Ruby:

auto fifth = new Symbol("5th-element.d");
import fifth;

Symbol could also contain logic for handling [de]mangling of symbols:

void foo();
auto str = foo.toSymbol.mangled();

this can simplify the language/compiler. all the logic for handling 
alias would be moved into this type, for example, alias template 
parameters would be typed as Symbols:

template foo(int i, Symbol s) { ... }



More information about the Digitalmars-d mailing list