Using DMD 2.057, I cannot get the following code to compile:
import std.stdio;
import std.array;
enum direction
{
test1,
test2,
test3
}
string getDescriptionOnConnect(direction d)
{
string descriptionOnConnect = "Going in direction %dir%";
foreach(s; __traits(allMembers, direction))
{
if (identifier(d) == s)
{
descriptionOnConnect =
replace(descriptionOnConnect, "%dir%", identifier(d));
}
}
return descriptionOnConnect;
}
int main(string[] argv)
{
return 0;
}
I get an error Error: undefined identifier identifier, although this keyword is clearly defined in the documentation at http://www.d-programming-language.org/traits.html#identifier . I also tried __identifier, but I got the same error. Is it not implemented yet?
source
share