Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Which class are functions in C? It was my impression that the only thing missing were anonymous functions, but there are pointers to functions if I'm not mistaken.


> Which class are functions in C?

Economy class. :-)

In general, how do you write functions that return functions without some form of anonymous function? For instance, how do you write a function that takes an int a and returns a function that takes an int parameter and returns non-zero if and only if that parameter is greater than a?


You can use function pointers. Functions in C are not first class (they are not a type) but you can emulate higher order functions crudely using function pointers.

It gets ugly pretty quick though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: