Annotations or custom attributes

Manu turkeyman at gmail.com
Fri Mar 9 09:45:47 PST 2012


On 9 March 2012 19:23, Michel Fortin <michel.fortin at michelf.com> wrote:

> On 2012-03-09 16:15:30 +0000, Andrei Alexandrescu <
> SeeWebsiteForEmail at erdani.org**> said:
>
>  I think a good approach in D would be to define mixins that work in
>> conjunction with the feature involved, for example:
>>
>> class A {
>>     int thing;
>>     mixin(DoNotSerialize!"thing");
>>     ...
>> }
>>
>> or together:
>>
>> class A {
>>     mixin(DoNotSerialize!(int, "thing"));
>>     ...
>> }
>>
>
> It's ugly, but it works… only to a point though. Try to annotate
> overloaded functions and it'll become a mess: either you duplicate the
> function name and all the argument types for each function, or you wrap the
> whole function body in the mixin.
>
> If you need to annotate a struct or a class you'll have the same problem,
> just at a bigger scale. And it gets worse if you want to annotate templated
> types and functions: how can the attribute apply to each instance?
>
> I'm not saying any of this is impossible using mixins, just that it
> becomes impractical as you go beyond the most simple cases.


It seems to me that everyone agrees on the usefulness of proper user
defined annotations, so I'm personally satisfied that it *will* come :) ..
It's certainly not urgent for me, but it sure would be nice!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120309/969e0427/attachment.html>


More information about the Digitalmars-d mailing list