2 ms·
It'd be nice to have a form of currying in C/C++ as applied to function pointers. Specifically, if I have int foo(void * bar, int baz); then I should be abl
by huhtenberg 14y ago
It'd be nice to have a form of currying in C/C++ as applied to function pointers. Specifically, if I have
int foo(void * bar, int baz);
then I should be able to use
foo(, 10)
where
int (*)(void *)
is expected.
Taking it beyond constant-based specialization would obviously require a support for closures, but I think it's a safe bet that the standard C will get it sooner rather than later.
- Someone 14y agoSafe bet? For C, I am not sure of that. They would want to stay close to the metal, and have true function pointers. Creating those on the fly means having them in the data segment (or some horrendous OS-specific and likely slow hack), and that is at odds with data execution prevention. C++ already has them, sort of. Templates accept 'anything that you can put () behind'. That includes function pointers and operator() overloads.
- CJefferson 14y agoIn C++11, you can write bind(f,_1,10). Not quite as neat, but not bad.
- huhtenberg 14y agoA lot of things are possible with C++, but they are universally just that - "not quite as neat". :)