www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Get complete function declaration

reply SrMordred <patric.dexheimer gmail.com> writes:
There is a way to get the full function(or any other structure) 
declaration with traits? Or I will have to mount it with 
std.traits functions?

eg.
void add(int x, int y){}

GetFullFunctionDeclaration!add; //return "void add(int x, int y)"
Jul 18
parent reply Ivan Kazmenko <gassa mail.ru> writes:
On Tuesday, 18 July 2017 at 13:35:49 UTC, SrMordred wrote:
 There is a way to get the full function(or any other structure) 
 declaration with traits? Or I will have to mount it with 
 std.traits functions?

 eg.
 void add(int x, int y){}

 GetFullFunctionDeclaration!add; //return "void add(int x, int 
 y)"
There are several function traits in std.traits (see https://dlang.org/phobos/std_traits.html), which can hopefully be combined to reconstruct a function declaration. I don't see a single method which would do what you want out of the box. Perhaps there is none, since different use cases would require different small subsets of features, and all the orthogonal features are already available. Ivan Kazmenko.
Jul 18
parent SrMordred <patric.dexheimer gmail.com> writes:
On Tuesday, 18 July 2017 at 13:53:11 UTC, Ivan Kazmenko wrote:
 On Tuesday, 18 July 2017 at 13:35:49 UTC, SrMordred wrote:
 There is a way to get the full function(or any other 
 structure) declaration with traits? Or I will have to mount it 
 with std.traits functions?

 eg.
 void add(int x, int y){}

 GetFullFunctionDeclaration!add; //return "void add(int x, int 
 y)"
There are several function traits in std.traits (see https://dlang.org/phobos/std_traits.html), which can hopefully be combined to reconstruct a function declaration. I don't see a single method which would do what you want out of the box. Perhaps there is none, since different use cases would require different small subsets of features, and all the orthogonal features are already available. Ivan Kazmenko.
Thanks! I´ll have to build one so :)
Jul 18