First-class Citizen - Examples

Examples

In C and C++, it is not possible to create new functions at runtime, whereas other kinds of objects can. 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 (+, -, etc.) are methods, they are also first-class objects.

In many older languages (for example C) arrays were not first-class: they could not be assigned as objects or passed as a parameter to a subroutine; only their elements could be directly manipulated. Few languages support continuations and GOTO-labels as first-class objects, though arguably they don't support them as objects at all.

Concept Description Languages
first-class function closures Scheme, ML, Haskell, F Sharp
first-class control continuations Scheme, ML, F Sharp
first-class type Coq
first-class data type Generic Haskell
first-class polymorphism impredicative polymorphism
proof object Coq, Agda

Read more about this topic:  First-class Citizen

Famous quotes containing the word examples:

    Histories are more full of examples of the fidelity of dogs than of friends.
    Alexander Pope (1688–1744)

    In the examples that I here bring in of what I have [read], heard, done or said, I have refrained from daring to alter even the smallest and most indifferent circumstances. My conscience falsifies not an iota; for my knowledge I cannot answer.
    Michel de Montaigne (1533–1592)

    There are many examples of women that have excelled in learning, and even in war, but this is no reason we should bring ‘em all up to Latin and Greek or else military discipline, instead of needle-work and housewifry.
    Bernard Mandeville (1670–1733)