<div dir="ltr">On 29 May 2013 01:45, Kenji Hara <span dir="ltr"><<a href="mailto:k.hara.pg@gmail.com" target="_blank">k.hara.pg@gmail.com</a>></span> wrote:<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"><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"><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"><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">

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"><br></div><div class="gmail_extra">
I think it is not implementable.</div></div></div></blockquote><div><br></div><div style>Well, until now, the lowering of an attribute to a scoped attribute would have always worked seamlessly, since no hard attributes ever received arguments.</div>
<div style>I'd suggest that it may no longer be reasonable behaviour to lower an attribute to a scoped attribute.</div><div style><br></div><div style><span style="font-family:arial,sans-serif;font-size:14px">@attribute("target", T) void func(string T)() {}</span><br>
</div><div style><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:14px">@attribute("target", T) { ...stuff...</span><span style="font-family:arial,sans-serif;font-size:14px"> void func(string T)() {} ...stuff... </span><span style="font-size:14px;font-family:arial,sans-serif">}</span></div>
</div><div><br></div><div><div>The 2 cases are quite distinct.</div><div>In the first, it looks very much like the the attribute is attributing the declaration (it really is PART of the declaration), and as such, should have access to any arguments supplied to the declaration.</div>
</div><div style>In the second case, it's quite clear that there is an outer scope. Any reasonably programmer will expect that parameters to an inner declaration will not be available in the outer scope.</div><div><br>
</div><div style>The issue seems to be an implementation detail, which was based on a premise that's no longer strictly true.</div><div><br></div><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 class="gmail_extra"><span class=""><font color="#888888"><div class="gmail_extra">Kenji Hara</div></font></span><div><div class="h5"><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><div><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></div></div>
</blockquote></div><br></div></div>