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

Cristian Baboi cristian.baboi at gmail.com
Sat Dec 22 09:47:52 EST 2007

On Sat, 22 Dec 2007 16:25:26 +0200, Miguel Mitrofanov  
<miguelimo38 at yandex.ru> wrote:

>>> 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.

These two different programs come together.

>>> 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?


h is g

>>> 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