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

Cristian Baboi cristian.baboi at gmail.com
Sat Dec 22 09:00:45 EST 2007

------- Forwarded message -------
From: "Cristian Baboi" <cristian.baboi at gmail.com>
To: "Jules Bean" <jules at jellybean.co.uk>
Subject: Re: [Haskell-cafe] Functions are first class values in C
Date: Sat, 22 Dec 2007 15:58:50 +0200

On Sat, 22 Dec 2007 14:09:13 +0200, Jules Bean <jules at jellybean.co.uk>

> Cristian Baboi wrote:
>> Let me show you an example to prove it.

> 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

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

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

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

> The ability to write type-safe functions with polymorphic arguments.

I didn't know this must be a property of first-class functions.
C is staticaly typed, so type errors will be detected.

Haskell is just C with some syntactic sugar :-)

More information about the Haskell-Cafe mailing list