custom attribute proposal (yeah, another one)

Steven Schveighoffer schveiguy at yahoo.com
Fri Apr 6 13:40:54 PDT 2012


On Fri, 06 Apr 2012 15:06:47 -0400, Piotr Szturmaj <bncrbme at jadamspam.pl>  
wrote:

> Steven Schveighoffer wrote:
>> On Fri, 06 Apr 2012 13:33:33 -0400, Tove <tove at fransson.se> wrote:
>>> I think this proposal pretty much covers what I would expect from
>>> 'custom attributes'... but what about adding a D twist, getting "what
>>> we annotate" as a template parameter so that one among other things
>>> can make use of Template Constraints?
>>
>> Interesting, so something like:
>>
>> @attribute string defaultName(T)() if(is(typeof(T.init.name))) { return
>> T.init.name;}
>>
>> Not sure how much this gives us, but it definitely feels doable.
>
> 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!

-Steve


More information about the Digitalmars-d mailing list