Template args to UDA's

Timon Gehr timon.gehr at gmx.ch
Fri May 31 03:47:07 PDT 2013


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.


More information about the Digitalmars-d mailing list