<br><br><div class="gmail_quote">On Fri, Jan 4, 2013 at 9:59 PM, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 1/4/13 3:51 PM, Walter Bright wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></blockquote>
</div></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So, I'm testing how to transfer UDA from one symbol to another.<br>
</blockquote>
<br><br>
This will do the transfer:<br>
<br>
import std.stdio;<br>
void main()<br>
{<br>
@(3, "hello") int i = 10;<br>
@(__traits(getAttributes, i)) double d2;<br>
writeln("[",__traits(<u></u>getAttributes, d2), "]");<br>
}<br></blockquote></div></div></blockquote><div><br></div><div>Yes, I know. I just want to automate the process. I want a function or some piece of code that can propagate attributes. </div><div>For example, say I receive a piece of unvalidated input. I test it and it's OK. I want to return it, with a new attribute (say, Validated() ),while keeping the input attributes. Since it seems a common need, I was looking for a way to abstract the process somewhat.</div>
<div><br></div><div>For now, we would return a Validated(initialValue) struct. I just want to see how attributes can be used here. It seems that:</div><div><br></div><div>@(Validated, __traits(getAttributes, input)) InputType temp;</div>
<div>return temp;</div><div><br></div><div>do not work.</div><div><br></div><div>If attribute manipulation cannot be isolated in easily reusable code, that would be sad.</div><div><br></div><div><br></div><div><br></div><div>
Andrei:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

</blockquote>
<br></div></div>
For transfer templates are better than attributes.</blockquote><div><br></div><div>Could you please give an example?</div></div>