"Nick Sabalausky" <a...@a.a> wrote in message 
news:gp78hj$b2...@digitalmars.com...
> -------------
> // Something along these lines...
> template generateEnum(char[] name, values...)
> {
>    const char[] generateEnum = "enum "~name~"{"~/*values*/~"}"~
>        "char[] enumToString("~name~" arg) { "~/*big switch(arg) 
> here*/~"}";
> }
> mixin(generateEnum!("Shape", "Square", "Circle", "Triangle"));
> Shape s = Shape.Triangle;
> Stdout.formatln("{}", enumToString (s));
> -------------
>

Ok, so apparently D2 phobos already has this in std.typecons (saw that in a 
reply over at ".D.learn"), but the main point of my post still remains. That 
point being, it looks terrible and annotations could make it (and anything 
similar) look not-terrible. 


Reply via email to