<div dir="ltr"><div>It looks reasonable, but in general case it would introduce not trivial semantic issue.</div><div><br></div><div>Based on the current D language spec, prefix attribute is just rewritten to blocked attribute.<br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:14px">@attribute("target", T) void func(string T)() {}</span></div><div class="gmail_extra"><font face="arial, sans-serif"><span style="font-size:14px"><br>
</span></font></div><div class="gmail_extra" style><font face="arial, sans-serif"><span style="font-size:14px">to:</span></font></div><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:14px">@attribute("target", T) {</span></div>
<div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:14px">    void func(string T)() {}</span></div><div class="gmail_extra"><font face="arial, sans-serif"><span style="font-size:14px">}</span></font></div>
<div class="gmail_extra"><font face="arial, sans-serif"><span style="font-size:14px"><br></span></font></div><div class="gmail_extra"><font face="arial, sans-serif"><span style="font-size:14px">And block attribute can contain other declarations.</span></font></div>
<div class="gmail_extra"><font face="arial, sans-serif"><span style="font-size:14px"><br></span></font></div><div class="gmail_extra"><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:14px">@attribute("target", T) {</span></div>
<div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:14px"><br></span></div><div class="gmail_extra" style><span style="font-family:arial,sans-serif;font-size:14px">    enum str = T.stringof;</span></div>
<div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:14px"><br></span></div><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:14px">    void func(string T)() {}</span></div>
<div class="gmail_extra"><font face="arial, sans-serif"><span style="font-size:14px">}</span></font></div><div><font face="arial, sans-serif"><span style="font-size:14px"><br></span></font></div><div class="gmail_extra" style>
Well, if the enhancement is implemented, T would be deduced by the each call of template function foo. Then the enum value would become undeterministic.</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>
I think it is not implementable.</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>Kenji Hara</div><div class="gmail_extra"><br></div><br><div class="gmail_quote">2013/5/28 Manu <span dir="ltr"><<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Indeed it does.<div>It's a bit obtuse though having to wrap my function up in an outer template just to scope the template arg correctly.</div>
<div><br></div><div>Do you think it's reasonable that an attribute should be scoped such that it can see the template args of the declaration it's bound to?</div>
<div>It kinda makes sense, an attribute is intrinsically connected to the declaration, so it should be able to access any template args given...</div></div><div class=""><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">
On 28 May 2013 23:51, Kenji Hara <span dir="ltr"><<a href="mailto:k.hara.pg@gmail.com" target="_blank">k.hara.pg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div>2013/5/28 Manu <span dir="ltr"><<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>></span><br>

<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">So I've run into an expression I need to be able to implement std.simd properly for GDC/LDC.<div><br></div><div>Doesn't work:</div><div>  @attribute("target", T) void func(string T)(...);</div>



<div><br></div><div>In this case, currently, the UDA can't receive the template arg that was given to the function.</div><div><br></div><div>I require that attributes on templates be able to make use of the template args, since the template arg given may affect the attribute in some circumstances.</div>



</div>
</blockquote></div><br></div></div></div><div class="gmail_extra">This code works.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">string attribute(string, string s) { return s; }</div>


<div class="gmail_extra"><br></div><div class="gmail_extra">//@attribute("target", T) void func(string T)() {}</div><div class="gmail_extra">template func(string T)</div><div class="gmail_extra">{</div><div class="gmail_extra">


    @attribute("target", T) void func() {}</div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div><div class="gmail_extra">void main()</div><div class="gmail_extra">{</div><div class="gmail_extra">


    alias f1 = func!"a";</div><div class="gmail_extra">    alias f2 = func!"b";</div><div class="gmail_extra">    pragma(msg, __traits(getAttributes, f1));   // "a"</div><div class="gmail_extra">


    pragma(msg, __traits(getAttributes, f2));   // "b"</div><div class="gmail_extra">    f1();</div><div class="gmail_extra">    f2();</div><div class="gmail_extra">}</div><span><font color="#888888"><div>
<br></div><div>Kenji Hara</div>
</font></span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>