First-class object

From Wikipedia, the free encyclopedia

(Redirected from First-class (object))
Jump to: navigation, search

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-1960's.[1]

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 constructable 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; one however may argue that they are not first-class objects, because while new operators can be declared, it is not possible (for example) to modify their precedence.

In virtually all languages, 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.

  1. ^ Rod Burstall, "Christopher Strachey—Understanding Programming Languages", Higher-Order and Symbolic Computation 13:52 (2000)

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.