<div class="gmail_quote">On 16 March 2012 16:51, Adam D. Ruppe <span dir="ltr"><<a href="mailto:destructionator@gmail.com">destructionator@gmail.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 Friday, 16 March 2012 at 14:11:35 UTC, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Surely the term you're looking for here is @annotate(...) ?<br>
</blockquote>
<br></div>
Meh, I don't care that much about names. I went<br>
with "note" anticipating people would complain about<br>
@add_user_defined_attribute() being too long :)<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What if you want to annotate with a variable?<br>
</blockquote>
<br></div>
That *might* work because a variable is an expression too.<br>
I'm not sure though. Will probably have to implement to<br>
know for sure.<br>
<br>
Of course, a constant can be represented as a struct<br>
for name and value:<br>
<br>
struct Description { string s; }<br>
<br>
@note(Description("yada yada yada")) int a;<div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Surely this is just as easy: @modulename.attribute int myThing;<br>
</blockquote>
<br></div>
Yeah, I think so. I remember this being a counterpoint<br>
last time we talked about it, but I don't recall the<br>
specific argument made.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Perhaps that's the key distinction between 'annotation' and a 'custom attributes' .. an annotation this way is a shared compile time constant, associating with its type info, as you suggest. A custom attribute is an instance-specific association vontaining variable data.<br>

</blockquote>
<br></div>
Yeah, "annotation" might be the better word. That's<br>
what I want here, but too late to change the subject name<br>
now.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
attribute myAttribute<br>
</blockquote>
<br>
I think this could be done as a struct, but I haven't<br>
used this kind of attribute at all so not sure...<br>
<br>
But what I'm thinking is:<br>
<br>
struct myAttribute(Type) {<br>
   Type value;<br>
   alias value this;<br>
<br>
   bool bNeedsAttention;<br>
   @property void refresh(bool bRefresh) { bNeedsAttention = bRefresh; }<br>
}<br>
<br>
myAttribute!int thing;<br>
thing.refresh = true;<br>
<br>
and thing can be substituted for an int anywhere else.<br>
</blockquote></div><br><div>Interesting approach, how will that affect 'thing's type?</div>