Idea For Attributes/Annotations
Nick Sabalausky
a at a.a
Tue Mar 10 19:50:13 PDT 2009
"Nick Sabalausky" <a at a.a> wrote in message
news:gp78hj$b26$1 at 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.
More information about the Digitalmars-d
mailing list