Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
First-class citizen
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples== The simplest [[Scalar (computing)|scalar]] data types, such as integer and floating-point numbers, are nearly always first-class. In many older languages, [[array data type|arrays]] and strings are not first-class: they cannot be assigned as objects or passed as parameters to a subroutine. For example, neither [[Fortran IV]] nor [[C (programming language)|C]] supports array assignment, and when they are passed as parameters, only the position of their first element is actually passed—their size is lost. C appears to support assignment of array [[pointer (computing)|pointers]], but in fact these are simply pointers to the array's first element, and again do not carry the array's size.{{citation needed|date=January 2022}} In most languages, [[data types]] are not first-class objects, though in some object-oriented languages, [[Class (computer programming)|classes]] are first-class objects and are instances of [[metaclass]]es. Languages in the [[functional programming]] family often also feature first-class types, in the form of, for example, [[generalized algebraic data type]]s, or other metalanguage amenities enabling programs to implement extensions to their own implementation language. Few languages support [[continuation]]s and [[GOTO]]-labels as objects at all, let alone as first-class objects. {| class=wikitable ! Concept !! Description !! Languages |- | [[first-class function]] || [[closure (computer science)|closure]]s and [[anonymous function]]s || [[Smalltalk]], [[Dart (programming language)|Dart]], [[Scheme (programming language)|Scheme]], [[ML (programming language)|ML]], [[Haskell (programming language)|Haskell]], [[F Sharp (programming language)|F#]], [[Kotlin (programming language)|Kotlin]], [[Scala (programming language)|Scala]], [[Swift (programming language)|Swift]], [[Perl]], [[PHP]], [[Python (programming language)|Python]], [[Raku (programming language)|Raku]], [[JavaScript]], [[Delphi (programming language)|Delphi]], [[Rust (programming language)|Rust]], [[Common Lisp#Functions|Common Lisp]] |- | [[first-class control]] || [[continuation]]s || [[Scheme (programming language)|Scheme]], [[ML (programming language)|ML]], [[F Sharp (programming language)|F#]] |- | [[first-class type]] || [[dependent types]] || [[Coq (software)|Coq]], [[Idris (programming language)|Idris]], [[Agda (programming language)|Agda]] |- | [[first-class data type]] || || [[Generic Haskell]], C++11 |- | [[first-class polymorphism]] || [[impredicative polymorphism]] || |- | [[first-class message]] || dynamic [[message (object-oriented programming)|message]]s (method calls) || [[Smalltalk]],<ref name="shroff-smith">Paritosh Shroff, Scott F. Smith. ''[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.114.4468&rep=rep1&type=pdf Type Inference for First-Class Messages with Match-Functions]''</ref> [[Objective-C]],<ref name="shroff-smith" /> [[Generic_function#In_Common_Lisp_Object_System|Common Lisp]] |- | [[first-class class]] || [[metaclass]] and [[metaobject]] || [[Smalltalk]], [[Objective-C]], [[Ruby (programming language)|Ruby]], [[Python (programming language)|Python]], [[Delphi (programming language)|Delphi]], [[Common Lisp#Common_Lisp_Object_System_(CLOS)|Common Lisp]] |- | first-class proofs <!-- proofs are first-class in IIT according to "Dependent Types at Work" --> || [[proof object]]<ref>{{cite book|last2=Dybjer|first2=Peter|date=2009|chapter=Dependent Types at Work|chapter-url=http://www.cse.chalmers.se/~peterd/papers/DependentTypesAtWork.pdf|title=Language Engineering and Rigorous Software Development|volume=5520|pages=57–99|doi=10.1007/978-3-642-03153-3_2|last1=Bove|first1=Ana|series=Lecture Notes in Computer Science |isbn=978-3-642-03152-6 |access-date=8 June 2015|url-status=live|archive-url=https://web.archive.org/web/20140402095457/http://www.cse.chalmers.se/~peterd/papers/DependentTypesAtWork.pdf|archive-date=April 2, 2014}} <!-- add back if original becomes obsolete | archiveurl = https://web.archive.org/web/20140402095457/http://www.cse.chalmers.se/~peterd/papers/DependentTypesAtWork.pdf | archivedate = 2014-04-02}} --> (also [http://www.cse.chalmers.se/~peterd/papers/DependentTypesAtWork.pdf archived])</ref> || [[Coq (software)|Coq]], [[Agda (programming language)|Agda]] |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)