First-class citizen

A first-class object (English first-class object) referred to in the programming of computer systems, an object that occurs as a function parameter or return value of a function or procedure or a variable can be assigned.

The term was coined by Christopher Strachey in context " functions as first -class citizens " in the mid 1960s.

Definition

An object is first class if it satisfies the following conditions:

  • It can be stored in program variables
  • It can be passed as parameters to functions or procedures
  • It can serve as a return value from functions
  • It can be created at run time of a program
  • It has its own identity ( regardless of the name )

The term "object " does not have to be understood in the strict sense an object an object-oriented programming language. In most programming languages, in particular the basic data types, such as Integer and floating objects always first-class.

Examples

  • In C and C functions are not first-class objects, since it is not possible to generate at run-time - unlike, say, Integers. Arrays are not first-class objects, since they can not be passed as function parameters.
  • In Fortran strings are not first-class objects, since it is not possible to assign them to variables.
  • In most functional programming languages ​​(eg Scala, Smalltalk and Lisp dialects as different Scheme and Clojure, but not in Common Lisp ) - functions are first-class objects (or first-class functions).
  • The building on concepts from scratch and education -oriented visual programming language Scheme BYOB / Snap! provides a vivid and continuous access to first-class objects.

Swell

335482
de