11
I'm writing a C program that would, if had been a part of the language, benefit from, partial function application. I need to supply a function pointer with a fixed signature but sometime I need to call already written function that needs arguments.
I can write a lot of small functions, calling each other as:
// example, not actual code
void (*atJoystickLeft)(void); // fixed signature
.. code ..
atJoystickLeft = &func1;
.. code ..
void func1(void) { func2(10, "a string"); } /
I vould like instead:
atJoystickLeft = &func2(10, "a string");
so I can dispose of the function func1 that is only to set parameter for the call to func2.
That would make the code at least, 20% - 30% smaller. My simple question is: Do someone have a trick for emulating partial function application in C? (C99)