User Defined Attributes

Kapps opantm2+spam at gmail.com
Wed Nov 7 15:06:54 PST 2012


Awesome. Lack of UDA has really caused some very ugly workarounds 
in my code, and it's really nice to see that it's being solved 
now. Probably one of the most important missing features I've 
encountered.

I do agree however with preventing any built-in types / literals 
being used as an annotation. It's just not safe, completely goes 
around the module system, and is abused in the same way as it 
would be with C++ exceptions. In C# for example, all attributes 
are classes derived from Attribute. This makes things a bit more 
obvious, allows a common base type (probably not needed in D 
because it's done at compile-time), but is rather hackish in my 
opinion (plus, in D you may want structs as attributes?). I 
definitely would like to see something like the @attribute 
suggestion though. Using types not meant to be used as attributes 
as attributes is dangerous and leads to conflicts when people 
want it to mean different things. What does '@Vector3f(1, 1, 1) 
int a' even mean? What if people use it to mean different things? 
It's just as confusing as '@3 int a'.


More information about the Digitalmars-d-announce mailing list