Call function by its string name

John Colvin john.loughran.colvin at gmail.com
Sat Oct 19 09:56:48 PDT 2013


On Saturday, 19 October 2013 at 16:33:11 UTC, aldanor wrote:
> I was wondering if it was possible to call D functions by their 
> names (strings that are not known at compile time) and couldn't 
> find the answer anywhere in the documentation. Kinda like we 
> can instantiate objects with Object.factory, would it be 
> possible to somehow do the same with module-level functions? Or 
> maybe with non-static class methods?

You could make an associative array of function pointers with 
strings as keys. Probably not the best solution but it should 
work.


More information about the Digitalmars-d mailing list