First-class function
In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. This means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures. Some programming language theorists require support for anonymous functions (function literals) as well. In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type. The term was coined by Christopher Strachey in the context of "functions as first-class citizens" in the mid-1960s.
- Comment
- enIn computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. This means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures. Some programming language theorists require support for anonymous functions (function literals) as well. In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type. The term was coined by Christopher Strachey in the context of "functions as first-class citizens" in the mid-1960s.
- Has abstract
- enIn computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. This means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures. Some programming language theorists require support for anonymous functions (function literals) as well. In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type. The term was coined by Christopher Strachey in the context of "functions as first-class citizens" in the mid-1960s. First-class functions are a necessity for the functional programming style, in which the use of higher-order functions is a standard practice. A simple example of a higher-ordered function is the map 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 or returning them as results, especially in the presence of non-local variables introduced in nested and anonymous functions. Historically, these were termed the funarg problems, the name coming from "function argument". In early imperative languages these problems were avoided by either not supporting functions as result types (e.g. ALGOL 60, Pascal) or omitting nested functions and thus non-local variables (e.g. C). The early functional language Lisp took the approach of dynamic scoping, where non-local variables refer to the closest definition of that variable at the point where the function is executed, instead of where it was defined. Proper support for lexically scoped first-class functions was introduced in Scheme and requires handling references to functions as closures instead of bare function pointers, which in turn makes garbage collection a necessity.
- Is primary topic of
- First-class function
- Label
- enFirst-class function
- Link from a Wikipage to an external page
- rosettacode.org/wiki/First-class_functions
- www.ibm.com/developerworks/linux/library/l-highfunc/index.html
- web.archive.org/web/20110720102933/http:/lambda.uta.edu/cse5317/l12.ppt
- Link from a Wikipage to another Wikipage
- Ada (programming language)
- ALGOL 60
- ALGOL 68
- Anonymous function
- Anonymous inner class
- Array data structure
- Assignment (computer science)
- Associative array
- Blocks (C language extension)
- Boilerplate code
- C (programming language)
- C++
- C++11
- Cartesian closed category
- Category:Articles with example C code
- Category:Articles with example Haskell code
- Category:Compiler construction
- Category:Data types
- Category:Functional programming
- Category:Primitive types
- Category:Programming language theory
- Category:Subroutines
- Category theory
- Christopher Strachey
- Clojure
- Closed category
- Closure (computer programming)
- Closure (computer science)
- Common Lisp
- Compiled language
- Computer science
- C Sharp (programming language)
- Curry–Howard correspondence
- Dangling reference
- Data structure
- Defunctionalization
- Delegate (CLI)
- Delphi (programming language)
- Dynamically scoped
- Dynamic scoping
- Erlang (programming language)
- Eval
- Extensional equality
- First-class citizen
- First-class message
- Fold (higher-order function)
- Fortran
- F Sharp (programming language)
- Funarg problem
- Function (programming)
- Functional programming
- Function object
- Function pointer
- Function type
- Garbage collection (computer science)
- Global variable
- Go (programming language)
- Haskell (programming language)
- Higher-order function
- IBM developerWorks
- In-place
- Insertion sort
- Integer%5D -%3E %5BInteger
- Intensional equality
- Interpreted language
- Io (programming language)
- Iteration
- Java (programming language)
- Java 8
- JavaScript
- Julia (programming language)
- Kappa calculus
- Leonidas Fegaras
- Lexically scoped
- Limbo (programming language)
- Lisp (programming language)
- List (computing)
- Logical implication
- Lua (programming language)
- Man or boy test
- Map (higher-order function)
- Maple (software)
- Mathematica
- MATLAB
- Merge sort
- ML (programming language)
- Modus ponens
- Name (computer science)
- Nested function
- Newsqueak
- Non-local variable
- Oberon (programming language)
- Object code
- Objective-C
- OCaml
- Partial application
- Pascal (programming language)
- Perl
- Persistent data structure
- PHP
- Polymorphism (computer science)
- Program counter
- Programming language
- Purity (computer science)
- Python (programming language)
- Recursion
- Reference equality
- Referential transparency
- Rosetta Code
- Ruby (programming language)
- Rust (programming language)
- Scala (programming language)
- Scheme (programming language)
- Simply typed lambda calculus
- Smalltalk
- Source code
- Stable sorting algorithm
- Swift (programming language)
- Tcl
- Type theory
- Undecidable problem
- Upwards funarg problem
- Variable (computer science)
- SameAs
- First-class function
- First-Class-Funktion
- Função de primeira classe
- m.04ckct
- MTEd
- Q1344046
- Функции первого класса
- Функција прве класе
- Функція першого класу
- توابع کلاس اول
- முதல் வகுப்புச் செயலி
- 头等函数
- 第一級関数
- Subject
- Category:Articles with example C code
- Category:Articles with example Haskell code
- Category:Compiler construction
- Category:Data types
- Category:Functional programming
- Category:Primitive types
- Category:Programming language theory
- Category:Subroutines
- WasDerivedFrom
- First-class function?oldid=1098149405&ns=0
- WikiPageLength
- 27474
- Wikipage page ID
- 1163024
- Wikipage revision ID
- 1098149405
- WikiPageUsesTemplate
- Template:Data types
- Template:Further information
- Template:Main
- Template:No
- Template:Partial
- Template:Reflist
- Template:Short description
- Template:Slink
- Template:Yes