Template args to UDA's

Manu turkeyman at gmail.com
Fri May 31 03:57:01 PDT 2013


* fix = fit


On 31 May 2013 20:56, Manu <turkeyman at gmail.com> wrote:

> On 31 May 2013 20:47, Timon Gehr <timon.gehr at gmx.ch> wrote:
>
>> On 05/28/2013 05:45 PM, Kenji Hara wrote:
>>
>>> It looks reasonable, but in general case it would introduce not trivial
>>> semantic issue.
>>>
>>> Based on the current D language spec, prefix attribute is just rewritten
>>> to blocked attribute.
>>>
>>> @attribute("target", T) void func(string T)() {}
>>>
>>> to:
>>> @attribute("target", T) {
>>>      void func(string T)() {}
>>> }
>>>
>>>
>> It is my understanding as well, but where is this actually specified?
>>
>>  And block attribute can contain other declarations.
>>>
>>> @attribute("target", T) {
>>>
>>>      enum str = T.stringof;
>>>
>>>      void func(string T)() {}
>>> }
>>>
>>> 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.
>>>
>>> I think it is not implementable.
>>> ...
>>>
>>
>>
>> This does not follow.
>>
>> @attribute("target", T) void func(string T)() {}
>>
>> would simply need to be treated like:
>>
>>
>> template func(string T){
>>     @attribute("target", T) void func() {}
>> }
>>
>> (The same would then be done for other attributes.)
>>
>> I think it makes a difference only for UDA's and pragmas.
>>
>
> Or fully expanded:
>
> template func(string T) {
>   @attribute("target", T) {
>     void func() { }
>   }
> }
>
> This seems to fix the existing semantics rather nicely.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130531/c3b699a3/attachment.html>


More information about the Digitalmars-d mailing list