[Haskell-cafe] Functions are first class values in C

Miguel Mitrofanov miguelimo38 at yandex.ru
Sat Dec 22 09:25:26 EST 2007

>> That's not C.
>> That's the C preprocessor, which is a textual substitution macro  
>> language.
> Well, the preprocessor is part of the language in a way. These two  
> come
> together.

No. In fact, these are even two different programs, see man cpp.

>> Macros certainly aren't first class (you can't pass a macro to a  
>> function, only its expansion).
> In Haskell I cannot pass a function to a function, only its expansion.

What do you mean by "expansion"? Can you clarify this?

>> C does support function pointers, which are something like first  
>> class functions. The main things C lacks which people associate  
>> with true first-class function is:
>> The ability to construct anonymous/local functions.
> If you look at the example you will see I've done that.

No. Your "compose" macro is not a function; for example, you can't  
use it as an argument to itself (which is easy in Haskell: (.)(.))

>> The ability to capture local variables and return a function with  
>> some variables bound.
> If I can construct "anonymous" functions and "constants", I can  
> construct
> functions with some variables bound.

See above. You can't.

More information about the Haskell-Cafe mailing list