Function name
bearophile
bearophileHUGS at lycos.com
Thu Apr 22 17:38:39 PDT 2010
Adam D. Ruppe:
> How about this?
If the sequence of functions is known at compile-time your solution can be used, thank you.
I have changed your function a little so it keeps the same order (in a hash iteration order is arbitrary):
auto funcWithName(T...)() {
Tuple!(string, typeof(&T[0]))[] result;
foreach (t; T)
result ~= tuple(__traits(identifier, t), &t);
return result;
}
> import std.traits;
Why do you import std.traits?
> Btw, do we still need classinfo now that we have __traits?
I think __traits is (mostly) for compile-time, while classinfo is run-time.
(Surely there are ways to design a tidier compile-time and run-time reflection API).
Bye,
bearophile
More information about the Digitalmars-d
mailing list