Hacker News new | ask | show | jobs
by lanna 3498 days ago
No, wrong. You can pass pointers to functions in C.
1 comments

It is a bit snarky, but also has a ground truth: pointers to functions aren't functions.

More importantly, you cannot make functions in C. For example, one cannot write a function that, given pointers to functions that compute 1/x and sin(x), returns a pointer to a function that returns 1/sin(x)

That's not a function, that's a closure. And you can simulate that in C by creating a struct that contains the function pointer and the set of captured data (and then when you invoke the function you pass the struct to it as a parameter).
Yes, hence the distinction between first-class features and others, which you have to implement yourself.
The parent comment said C function pointers aren't functions. They are. They just aren't closures.