First class property
A first-class citizen ( English first-class object , German about "Object First Class") refers to the programming of computer systems an object as arguments or return value of a function or procedure occurs or a variable can be assigned.
The term was coined by Christopher Strachey in the context of functions as first-class citizens in the mid-1960s.
definition
An object is first class if it meets the following conditions:
- it can be saved in program variables,
- it can be passed as a parameter to functions or procedures,
- it can serve as a return value of functions,
- it can be created while a program is running and
- it has its own identity (regardless of name).
The term object does not have to be understood in the narrower sense as an object of an object-oriented programming language . In most programming languages, the objects of the elementary data types , e.g. B. Integer and floating point objects, always first class.
Examples
- In C and C ++ functions are not first class objects because it is not possible to create them at runtime - unlike e.g. B. Numbers . Also arrays are not first class objects, as they can not be passed as function parameters.
- In Fortran , strings are not first class objects because they cannot be assigned to variables.
- In contrast, functions in most functional programming languages are first-class objects (or first-class functions ) e.g. B. in Haskell , Scala , Smalltalk , OCaml and various Lisp dialects such as Scheme and Clojure , but not in Common Lisp .
- The educational visual programming language Snap! Based on the concepts of Scratch and Scheme . provides clear and consistent access to first-class properties.
swell
- ^ Michael Scott: Programming Language Pragmatics . Morgan Kaufmann Publishers, San Francisco, CA 2006, p. 140.
- ^ Rod Burstall, "Christopher Strachey — Understanding Programming Languages," Higher-Order and Symbolic Computation 13 : 52 (2000)
- ↑ First Class . C2.com. January 25, 2006. Retrieved October 9, 2010.
- ^ First class object . Catalysoft.com. Retrieved October 9, 2010.