The pseudo code for what I want to do is:
function<bool(int)> getFunc(type) // get a function depending on what type is passed
problem is the function to return must be declared as static? As a result, I can't access object properties. So I need to pass them into the function? Thus, the original function to return might look like:
bool func1(int)
bool func2(int)
Now needs to be injected with other objects/arguments it need to run ...
bool func1(int, Class1)
bool func2(int, Class2)
So how do I define the return type of getFunc
? Or maybe theres a better way?
UPDATE
In the above, func*
functions are actually: has*()
. eg.
hasStmtsUsing(variable)
hasVariablesUsed(stmt)
And to determine if the condition is true, it uses an object eg. uses
. Then there are other similar has*()
functions like hasStmtsModifying(variable)
that uses an object modifies
. uses
and modifies
are objects of different types, and originally, they are object members, thus dont need to be passed in. Now since the functions are static
, they need to be passed in.
While writing this, I am thinking what I need is some kind of dependency injector? Maybe I pass in DI
and call DI.getX()
functions?