Content deleted Content added
→Availability: added Io to the list of languages that support first class functions |
«"map" → "map"» we have an article on that y;know |
||
Line 1:
In [[computer science]], a [[programming language]] is said to support '''first-class functions''' if it treats [[function (programming)|function]]s as [[first-class object]]s. Specifically, this means that functions can be created during the execution of a program, stored in data structures, passed as arguments to other functions, and returned as the values of other functions.
These features are a necessity for the [[functional programming]] style, in which (for instance) the use of [[higher-order function]]s is a standard practice. A simple example of a higher-ordered function is the ''[[Map (higher-order function)|map]]'' or ''mapcar'' function, which takes as its arguments a function and a list, and returns the list formed by applying the function to each member of the list. For a language to support ''map'', it must support passing a function as an argument.
There are certain implementation difficulties in passing functions as arguments and returning them as results. Historically, these were termed the [[funarg problem]]s, the name coming from "function argument". A different set of difficulties arises when programs can create functions at runtime; if the program is compiled, this means that the runtime environment must itself include a compiler.
|