getting the adress of a function by its name in string format

nikki via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 30 10:15:05 PDT 2014


On Saturday, 30 August 2014 at 17:08:30 UTC, Philippe Sigaud via 
Digitalmars-d-learn wrote:
>> instead I would like to use "EAT_FOOD_DECISION" and 
>> "EAT_FOOD_BEHAVIOUR" and
>> get the functions?
>>
>> Is that possible somehow?
>
> If all your functions had the same signature, you could use an
> associative array  FunctionType[string] and initialize it:
>
> FunctionType[string] myFuncs;
> myFuncs["EAT_FOOD_DECISION"] = &EAT_FOOD_DECISION;
>
> But it seems they have different types?

I think that is the best solution indeed, there are only two 
types(BevaviorFunc and DeciderFunc), so two dictionaries instead.

It also solves another issue of not having strings for naming the 
functions in logs.


More information about the Digitalmars-d-learn mailing list