码迷,mamicode.com
首页 > 其他好文 > 详细

First-class citizen

时间:2018-01-21 00:01:39      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:support   meta   nbsp   gpo   lang   poi   i/o   operation   int   

In programming language design, a first-class citizen (also typeobjectentity, or value) in a given programming language is an entity which supports all the operations generally available to other entities. These operations typically include being passed as an argument, returned from a function, modified, and assigned to a variable.[1]

 

The simplest scalar data types, such as integer and floating-point numbers, are nearly always first-class.

In many older languages, 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 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 pointers, but in fact these are simply pointers to the array‘s first element, and again do not carry the array‘s size.

In most languages, data types are not first-class objects, though in some object-oriented languages, classes are first-class objects and used for metaclasses.

Few languages support continuations and GOTO-labels as objects at all, let alone as first-class objects.

ConceptDescriptionLanguages
first-class function closures and anonymous functions SchemeMLHaskellF#ScalaSwiftPHPPerl 6JavaScript
first-class control continuations SchemeMLF#
first-class type   CoqIdris
first-class data type   Generic Haskell. C++11
first-class polymorphism impredicative polymorphism  
first-class message dynamic messages (method calls) Smalltalk,[7] Objective-C[7]
first-class class metaclass SmalltalkObjective-CRubyPython
  proof object[8] CoqAgda

First-class citizen

标签:support   meta   nbsp   gpo   lang   poi   i/o   operation   int   

原文地址:https://www.cnblogs.com/feng9exe/p/8322295.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!