cdiggins.com

December 8, 2007

First Class Values and First Class Functions

Filed under: Everything — cdiggins @ 6:05 pm

There was some discussion about a formal definition of first class values and first class functions at Lambda-the-Ultimate.org recently. Here is my definition of first class values: 

A first class value is a value which can be passed as a parameter to a procedure, returned as a result from an evaluated expression (e.g. function call), and constructed dynamically. A first class function is a function which is a first-class value. 

Informally a first class value shares the other common characteristics of values of the most fundamental types in the language (e.g. int, float, double, char, etc. in C) 

To use C as an an example, a function is missing two crucial properties to be considered first class. First it can’t be an l-value like any of the fundamental types: you can’t assign a function to another function, you can only assign references. Second you can’t create functions dynamically, you can only reference functions which have been declared in the source code. There is some confusion though unfortunately because pointers to functions are themselves first-class.

See also: Andreas Rossberg’s definition.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress