Re:Swift and the Legacy of Functional Programming
by lanna on Monday November 21, 2016 @12:20PM
(#13007060)
No, wrong. You can pass pointers to functions in C.
[ Parent
| on HN ]
Re:Swift and the Legacy of Functional Programming
by Someone on Monday November 21, 2016 @01:45PM
(#13007941)
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)
Re:Swift and the Legacy of Functional Programming
by eridius on Monday November 21, 2016 @01:58PM
(#13008066)
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).