enum strings in import

IGotD- nise at nise.com
Wed Apr 27 15:23:32 UTC 2022


Reading this concept it is clear that we need to change import to 
allow enum strings.

https://github.com/dlang/phobos/pull/8309

It can be done with mixins but the code becomes ugly. Instead 
compile time string enums should be accepted in the import 
argument.

The question is how to do this.

enum string somewhere = "location";

import this.that.somewhere.here;

This might fool many users and they start to look for the folder 
"somewhere" which might not exist. In order to clarify that you 
are using a compile time string you can be more obvious like.

import this.that.enum(somewhere).here;

Now it is more obvious that somewhere is a variable.


Another thing that I also noticed is how the version identifiers 
are just a sea of identifiers, many not orthogonal. Wouldn't it 
be time to let version have an argument. Like

version(OS == Windows)
{

}

This would it simpler for the import, then we could use.

import this.that.version(OS).here;



More information about the Digitalmars-d mailing list