custom attribute proposal (yeah, another one)

Piotr Szturmaj bncrbme at jadamspam.pl
Fri Apr 6 14:36:57 PDT 2012


Steven Schveighoffer wrote:
> On Fri, 06 Apr 2012 15:06:47 -0400, Piotr Szturmaj
>> See also: http://forum.dlang.org/post/jlmtcv$v09$1@digitalmars.com
>
> Excellent point, passing the symbol being annotated (probably should be
> an alias) should definitely be added. Then you could easily limit what
> attributes can be attached to!

Yes, I forgot to add "alias". I think this is the best approach to 
support attribute constraints. We can write some library mixins to 
support common cases like limiting the number of attributes or allowing 
simple targets (if we choose UDTs for attributes):

struct Attr
{
     // allows multiple attachments, but for classes and structs only
     mixin AttrConstraint!(true, AttrTarget.Class | AttrTarget.Struct);
}


More information about the Digitalmars-d mailing list