<div class="gmail_quote">On 9 March 2012 19:23, Michel Fortin <span dir="ltr"><<a href="mailto:michel.fortin@michelf.com">michel.fortin@michelf.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 2012-03-09 16:15:30 +0000, Andrei Alexandrescu <<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a><u></u>> said:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think a good approach in D would be to define mixins that work in conjunction with the feature involved, for example:<br>
<br>
class A {<br>
     int thing;<br>
     mixin(DoNotSerialize!"thing");<br>
     ...<br>
}<br>
<br>
or together:<br>
<br>
class A {<br>
     mixin(DoNotSerialize!(int, "thing"));<br>
     ...<br>
}<br>
</blockquote>
<br></div>
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.<br>

<br>
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?<br>

<br>
I'm not saying any of this is impossible using mixins, just that it becomes impractical as you go beyond the most simple cases.</blockquote><div><br></div><div>It seems to me that everyone agrees on the usefulness of proper user defined annotations, so I'm personally satisfied that it <u>will</u> come :) .. It's certainly not urgent for me, but it sure would be nice!</div>
</div>