The C syntax really makes this simple feature look terribly complicated. It's a while since I watched them, but in the SICP video lectures, as I recall, the notion of storing functions in variables - as introduced in, like, lecture 1 or 2 - took about 0.1% of the time - if indeed that. And that's because while the principles are actually more complicated than the C example (due to the lexically-scoped variable captur…
I think the only complicated-looking thing in C is the syntax for declaring function pointer types. If you use typedefs you end up with
typedef int (*math_op)(int, int);
math_op ops[] = {
add,
subtract
};
int a = ops[0](3, 5);
int b = ops[1](9, 2);
... maybe I've just used them too much, but I find them quite simple (except, as mentioned, setting up the initial typedefs which is a bit "odd").One of my favourite uses of function pointers is for key-mappings, like in: https://github.com/muennich/sxiv/blob/master/config.def.h