Proposal: user defined attributes

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Mar 22 05:11:46 PDT 2012


On 3/22/12, Kapps <opantm2+spam at gmail.com> wrote:
> 1) It wrecks things that use template arguments, possibly special
> casing for certain types.

Yeah I've noticed things tend to break with alias this. Anyway if
templates could be improved for these edge-cases then it's a benefit
for everyone, regardless of annotations. :)

> 2) It makes it difficult to combine attributes.

Difficult.. well maybe. You could use something like:
Attribute!(int, NonSerialized, Encrypted) ID1, ID2;

Or override opAssign and use bit masks:

Attribute!int ID1 = NonSerialized | Encrypted;
Attribute!int ID2 = NonSerialized | Encrypted;

With attributes this would maybe be:
@NonSerialized @Encrypted int ID1, ID2;

I do like the attribute syntax more.

> 3) It forces altering actual code to indicate an annotation, as
> opposed to just annotating it.

Yup.


More information about the Digitalmars-d mailing list