[Issue 10193] Template args to UDA's
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 28 08:48:29 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10193
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2013-05-28 08:48:27 PDT ---
(In reply to comment #0)
> Doesn't work:
> @attribute("target", T) void func(string T)(...);
You can write it as follows.
string attribute(string, string s) { return s; }
template func(string T)
{
@attribute("target", T) void func() {}
}
void main()
{
alias f1 = func!"a";
alias f2 = func!"b";
pragma(msg, __traits(getAttributes, f1)); // "a"
pragma(msg, __traits(getAttributes, f2)); // "b"
f1();
f2();
}
----
It looks reasonable enhancement, 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)() {} }
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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list