第一類物件

Multi tool use
第一類物件(英语:First-class object)在電腦科學中指可以在執行期創造並作為參數傳遞給其他函數或存入一個變數的實體[1]。將一個實體變為第一類物件的過程叫做「物件化」(Reification)[2]。
「第一類物件」這一名稱最早由克里斯托弗·斯特雷奇在1960年代發明,原稱「第一類公民」(First-class citizen),意指函數可作為電腦語言中的第一類公民。英文中也稱「First-class entity」或「First-class value」。
历史
第一类对象和第二类对象的概念,在1960年由克里斯托弗·斯特雷奇引入。[3][4] 实际上他并没有给出严格的术语定义,而是给出了ALGOL语言中实数和过程的对比:
第一类对象和第二类对象。在Algol程序语言中,一个“实数”可能会出现在一个表达式中或被赋给一个变量,并可能在过程调用中作为实际参数出现。而“过程”只可能会出现在另一个过程调用中,最常见的是作为操作符,有时候也作为实参。除此之外,没有表达式会涉及到过程,或者将过程作为计算结果。因此在某种意义上,在Algol程序语言中的过程是第二类变量,它们总是会单独出现,不可能被一个表达式或一个变量表示(形式参数除外)…[5]
在1990年代,拉斐尔芬克尔[6] 提出了第二类值和第三类值的定义,但这些定义尚未被广泛采用。[7]
定義
第一類物件不一定是物件導向程式設計所指的物件,而可以指任何程式中的實體。一般第一類物件所特有的特性為:
- 可以被存入變數或其他結構
- 可以被作為參數傳遞給其他函數
- 可以被作為函數的返回值
- 可以在執行期創造,而無需完全在設計期全部寫出
- 即使沒有被繫結至某一名稱,也可以存在
範例
絕大多數語言中,數值與基礎型別都是第一類物件,然而不同語言中對函數的區別很大,例如C語言與C++中的函數不是第一類物件,因為在這些語言中函數不能在執行期創造,而必須在設計時全部寫好。相比之下,Scheme中的函數是第一類物件,因為可以用lambda
語句來創造匿名函數並作為第一類物件來操作。
参考文献
^ Scott, Michael. Programming Language Pragmatics. San Francisco, CA: Morgan Kaufmann Publishers. 2006: 140.
^ J. Malenfant, M. Jacques and F.-N. Demers. A Tutorial on Behavioral Reflection and its Implementation. parc.com. [2010-10-09]. (原始内容存档于2010-05-28).
^ Rod Burstall, "Christopher Strachey—Understanding Programming Languages", Higher-Order and Symbolic Computation 13:52 (2000)
^ Harold Abelson; Gerald Jay Sussman. 章节1.3.4 脚注64. Structure and Interpretation of Computer Programs [计算机程序的构造和解释] 2. [2015-03-03]. (原始内容存档于2015-03-09) (英语).
^ Christopher Strachey, "Fundamental Concepts in Programming Languages" in Higher-Order and Symbolic Computation 13:11 (2000); though published in 2000, these are notes from lectures Strachey delivered in August, 1967
^ R. Finkel. Advanced Programming language Design. : 73 (英语).
^ Norman Ramsey. About first-,second- and third-class value. Stackoverflow. [14 September 2013] (英语).
GjSh0z,upd1MlozYDfHxGaWsn1DPJNq2QpPElWxANEvwF5ujpqa92w,86Mlysn 7r XbOaC,x dhQ,iGudUQ4I KbjgFdkJuPXi 5J6oFTs
Popular posts from this blog
Place in Moyen-Ogooué, Gabon Lambaréné Street in Lambaréné Lambaréné Location in Gabon Coordinates: 0°41′18″S 10°13′55″E / 0.68833°S 10.23194°E / -0.68833; 10.23194 Coordinates: 0°41′18″S 10°13′55″E / 0.68833°S 10.23194°E / -0.68833; 10.23194 Country Gabon Province Moyen-Ogooué Population (2013 census) • Total 38,775 Lambaréné is a town and the capital of Moyen-Ogooué in Gabon. With a population of 38,775 as of 2013, it is located 75 kilometres south of the equator. Lambaréné is based in the Central African Rainforest at the river Ogooué. This river divides the city into 3 districts: Rive Gauche, Ile Lambaréné and Rive Droite. The Albert Schweitzer Hospital and the districts Adouma and Abongo are located on Rive Droite. The districts Atongowanga, Sahoty, Dakar, Grand Village, Château, Lalala and Bordamur build the Ile Lambaréné. The majority of the people in Lambaréné live in the district Isaac located on Rive Gauche. This distr...
This article is about the number. For the year, see 800. For other uses, see 800 (disambiguation). Natural number ← 799 800 801 → List of numbers — Integers ← 0 100 200 300 400 500 600 700 800 900 → Cardinal eight hundred Ordinal 800th (eight hundredth) Factorization 2 5 × 5 2 Greek numeral Ω´ Roman numeral DCCC Binary 1100100000 2 Ternary 1002122 3 Quaternary 30200 4 Quinary 11200 5 Senary 3412 6 Octal 1440 8 Duodecimal 568 12 Hexadecimal 320 16 Vigesimal 200 20 Base 36 M8 36 800 ( eight hundred ) is the natural number following 799 and preceding 801. It is the sum of four consecutive primes (193 + 197 + 199 + 211). It is a Harshad number. Contents 1 Integers from 801 to 899 1.1 800s 1.2 810s 1.3 820s 1.4 830s 1.5 840s 1.6 850s 1.7 860s 1.8 870s 1.9 880s 1.10 890s 2 References Integers from 801 to 899 800s Main article: 801...
body.skin-minerva .mw-parser-output table.infobox caption{text-align:center} 維納斯堡 Venersborg (英文) CDP Venersborg, Washington 維納斯堡位置圖 坐标: 45°46′58″N 122°27′43″W / 45.7828°N 122.462°W / 45.7828; -122.462 國家 美國 州 華盛頓州 郡 克拉克县 面积 • 总计 27.8 平方公里(10.7 平方英里) • 陸地 27.8 平方公里(10.7 平方英里) • 水域 0.0 平方公里(0.0 平方英里) 海拔 155 米(509 英尺) 人口 (2000年) • 總計 3,274 • 密度 118.0/平方公里(305.6/平方英里) 时区 PST (UTC-8) • 夏时制 PDT(UTC-7) FIPS碼 53-74585 [1] GNIS編號 1527695 [2] 維納斯堡 ( 英语: Venersborg )是美国华盛顿州克拉克县的一個普查规定居民点(CDP),2000年美國人口普查時人口為2,085人。 最初為瑞典人聚居地。 參見 維納什堡 参考資料 ^ American FactFinder. United States Census Bureau. [ 2008-01-31 ] . ^ US Board on Geographic Names. United States Geological Survey. 2007-10-25 [ 2008-01-31 ] . 查 论 编 克拉克县 行政區劃 郡治 : 溫哥華 市 巴特爾格朗德 | 卡默斯 | 拉申特 | 里奇菲尔德 | 溫哥華 | 瓦休戈 | 林地市‡ 鎮 亞科爾特 CDP 安波伊 | 巴伯頓 | 布拉什普雷里 | 櫻桃樹叢區 | ...