5 ms·
What distinction are you drawing between "first-class functions" and "function pointers"?
by thaumasiotes 10y ago
What distinction are you drawing between "first-class functions" and "function pointers"?
- bunderbunder 10y agoAbout the same distinction as I'd draw between an integer and a pointer to an integer.
- kazinator 10y agoBoth function pointers and "first class functions" refer to function indirection. In its treatment of expressions, C doesn't draw the distinction between function and pointer to function. When you call printf("foo\n"), the printf part is a primary expression which designates a function, and evaluates to a function pointer. That pointer is then dereferenced by the postfix (). The main difference between a "first class" function and a function pointer is that a first class function carries an environment, which allows the body of the function to make references to lexically scoped names outside of the function. A function pointer carries a reference to the code only.
- moogleii 10y ago>The main difference between a "first class" function and a function pointer is that a first class function carries an environment Isn't that specifically a closure? I think first class functions have a more general definition.