On Saturday, 11 April 2015 at 19:08:50 UTC, Marco Leise wrote:
Am Sat, 11 Apr 2015 18:28:35 +0000
schrieb "Paul D Anderson" <claude.re...@msnmail.com>:

Is there a way to return the name of a function (a string) from a pointer to that function?

Function pointer example from D Reference:
---
int function() fp;

void test()
{
     static int a = 7;
     static int foo() { return a + 3; }

     fp = &foo;
}

void bar()
{
     test();
     int i = fp();       // i is set to 10
}
---

Can I get "foo" from fp?

Paul



Nope, that would require that fp not only contains a pointer
to the function but also a pointer to the name. That's not how
it works. But continuing that thought, you could add the
function's name as an additional variable and set that every
time you set fp.

Okay, thanks, I can see that.

Paul

Reply via email to