On 31 May 2013 20:47, Timon Gehr <timon.g...@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.