Proposal: user defined attributes

Kapps opantm2+spam at gmail.com
Thu Mar 22 04:06:00 PDT 2012


On Thursday, 22 March 2012 at 10:18:24 UTC, Andrej Mitrovic wrote:
> On 3/21/12, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> 
> wrote:
>> I think the liability here is that b needs to appear in two 
>> places.
>
> Andrei, how about this:
>
>
> Note that I've had to make a constructor because I can't 
> implicitly
> assign a string to a NonSerialized!string inside of a struct 
> literal
> (but I think this is just a DMD frontend bug).

Altering the type is not a reasonable approach for a generic 
annotation system.
1) It wrecks things that use template arguments, possibly special 
casing for certain types.
2) It makes it difficult to combine attributes.
3) It forces altering actual code to indicate an annotation, as 
opposed to just annotating it.

Honestly, C# already handles annotations perfectly (with the 
exception of too little compile-time power to specify the 
arguments), I see no reason to attempt to reinvent it. I've never 
had a problem where I thought that C#'s attributes were not 
sufficient.


More information about the Digitalmars-d mailing list