digitalmars.D.learn - Function overload pointers
- Daniel Ribeiro Maciel (7/7) Nov 06 2008 I'm having a problem to pass function overload pointers. I have the foll...
- Christopher Wright (3/12) Nov 07 2008 Yes, because __traits(getVirtualFunctions) returns final functions. Once...
- Daniel Ribeiro Maciel (14/28) Nov 07 2008 Oh, sorry, I did not express myself correctly.
I'm having a problem to pass function overload pointers. I have the following situation: void foo() { writefln( "hello" ); } void foo(int i) { writefln( "hello 1 int ", i ); } void foo(int i, int j) { writefln( "hello 2 int ", i, " ", j ); } I need to be able to build a tuple of all "foo"'s overloads such in as __traits( getVirtualFunctions, ... ), but "foo" is not virtual. Is it possible? Best regards, Daniel
Nov 06 2008
Daniel Ribeiro Maciel wrote:I'm having a problem to pass function overload pointers. I have the following situation: void foo() { writefln( "hello" ); } void foo(int i) { writefln( "hello 1 int ", i ); } void foo(int i, int j) { writefln( "hello 2 int ", i, " ", j ); } I need to be able to build a tuple of all "foo"'s overloads such in as __traits( getVirtualFunctions, ... ), but "foo" is not virtual. Is it possible?Yes, because __traits(getVirtualFunctions) returns final functions. Once that bug is fixed, it won't be nearly as possible.Best regards, Daniel
Nov 07 2008
Oh, sorry, I did not express myself correctly. What I actually meant was, I need to enumerate all "foo"'s overloads, but "foo" is not class methods, its a set of standalone functions. I need to do that in order to properly bind those overloads automatically to a scripting language. My final goal is to be able to write something like: export!( foo ); ... and be able to call any overload of "foo" from my scripting language, all detected automatically using compile time reflection. Is it possible? I understand that __traits( getVirtualFunctions ... ) needs a class and a method as argument and returns a tuple containing all virtual overloads of that method. That allows me to automatically bind all VIRTUAL methods of a class and it works great. Now I need a way to do the same for non-member functions and non-virtual functions. You said that there's a bug that allows me to reflect non-virtual member functions. How can I reflect non-member functions? Best Regards, Daniel Christopher Wright Wrote:Daniel Ribeiro Maciel wrote:I'm having a problem to pass function overload pointers. I have the following situation: void foo() { writefln( "hello" ); } void foo(int i) { writefln( "hello 1 int ", i ); } void foo(int i, int j) { writefln( "hello 2 int ", i, " ", j ); } I need to be able to build a tuple of all "foo"'s overloads such in as __traits( getVirtualFunctions, ... ), but "foo" is not virtual. Is it possible?Yes, because __traits(getVirtualFunctions) returns final functions. Once that bug is fixed, it won't be nearly as possible.Best regards, Daniel
Nov 07 2008