First-class object

First-class object

In computing, a first-class object (also value, entity, and citizen), in the context of a particular programming language, is an entity which can be used in programs without restriction (when compared to other kinds of objects in the same language). First-class objects are said to belong to a first-class data type.

The term was coined by Christopher Strachey in the context of “functions as first-class citizens” in the mid-1960s. [Rod Burstall, "Christopher Strachey—Understanding Programming Languages", "Higher-Order and Symbolic Computation" 13:52 (2000)]

Depending on the language, this can imply:

* being expressible as an anonymous literal value
* being storable in variables
* being storable in data structures
* having an intrinsic identity (independent of any given name)
* being comparable for equality with other entities
* being passable as a parameter to a procedure/function
* being returnable as the result of a procedure/function
* being constructible at runtime
* being printable
* being readable
* being transmissible among distributed processes
* being storable outside running processes

For example, in C and C++, it is not possible to create new functions at runtime (although see anonymous lambda bindings in the Boost library), whereas other kinds of objects can be created at runtime. As a result, functions in C are not first-class objects; instead, they are sometimes called second-class objects because they can still be manipulated in most of the above fashions (via function pointers). Similarly, strings are not first class objects in FORTRAN 66 because it is not possible to assign them to variables (unlike, for example, numbers).

In Smalltalk, functions (methods) are first class objects, just like Smalltalk classes. Since Smalltalk Operators (+, -) are methods, they are also objects.

In virtually all languages, values of the simplest data types, including integers and floating-point numbers, are first-class objects. In many older languages, arrays were not first-class: they could not be assigned as objects; only their elements could be directly manipulated. Few languages support closures, continuations, and GOTO-labels as first-class objects, though arguably they don't support them as objects at all.

Notes

See also

*First-class function
*Funarg problem


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • First-class function — In computer science, a programming language is said to support first class functions (or function literal) if it treats functions as first class objects. Specifically, this means that the language supports constructing new functions during the… …   Wikipedia

  • First-Class-Objekt — Ein first class Objekt (englisch first class object) bezeichnet in der Programmierung von Computersystemen ein Objekt, das als Übergabeparameter oder Rückgabewert einer Funktion oder Prozedur auftritt bzw. einer Variable zugewiesen werden kann.… …   Deutsch Wikipedia

  • First class — The term First class (or 1st class, Firstclass) generally implies a high level of service, importance or quality. Specific uses of the term include:* First class travel ** First class (aviation) * First Class mail * First class cricket * First… …   Wikipedia

  • Object (computer science) — In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure. (With the later introduction of object oriented programming the same word,… …   Wikipedia

  • Object-oriented programming — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computing …   Wikipedia

  • Class consciousness — Part of a series on Marxism …   Wikipedia

  • Object diagram — Example of a Object diagram. UML diagrams Structural UML diagrams …   Wikipedia

  • Class (computer programming) — In object oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable …   Wikipedia

  • Object-capability model — The object capability model is a computer security model based on the Actor model of computation. The name object capability model is due to the idea that the capability to perform an operation can be obtained by the following combination: an… …   Wikipedia

  • Object Constraint Language — The Object Constraint Language (OCL) is a declarative language for describing rules that apply to Unified Modeling Language (UML) models developed at IBM and now part of the UML standard. Initially, OCL was only a formal specification language… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”