- Does a language have first-class functions if it can use its functions to solve particular problems in a certain manner, or
- Does a language have first-class functions if functions are just as flexible as other types in the language itself?
Thursday, December 03, 2009
What is a first-class function?
There is a debate about it on Wikipedia, and I am curious:
SICP provides a definition of first-class status:
ReplyDeleteIn general, programming languages impose restrictions on the ways in which computational elements can be manipulated. Elements with the fewest restrictions are said to have first-class status. Some of the ``rights and privileges'' of first-class elements are:
* They may be named by variables.
* They may be passed as arguments to procedures.
* They may be returned as the results of procedures.
* They may be included in data structures.
[From: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-12.html#%_sec_1.3]
Thanks Pollux.
ReplyDeleteWith that definition, in isolation, then a dynamic language practitioner might include run-time creation of functions whereas a static language user would not.
Maybe it is item 2. and in a dynamic language you should include run-time function creation, but not for a static language, leading to two sets of likely properties of first-class functions depending.
@Pollux hit it right on the head!
ReplyDeleteIt's closer to your 2. than 1.!