第一類物件

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] (英语).
ryGeVwxmkq6tFn,4JEyHBF,Sg4pMnhRlOfuXyrP wax ohw2 14232FGhetwZv Lin5
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...
Harriet Andersson Harriet Andersson in 2014 Born ( 1932-02-14 ) 14 February 1932 (age 87) Stockholm, Sweden Nationality Swedish Occupation Actress Years active 1949–2007 Spouse(s) Bertil Wejfeldt ( m. 1959–1964) Bobo Håkansson ( m. 1980–1982) Partner(s) Per Oscarsson (1951–1953) Ingmar Bergman (1953–1955) Gunnar Hellström (1956–1958) Jörn Donner (1960s) Börje Åberg (1970s) Ulf Törnberg (1970s) Children 1 Harriet Andersson (born 14 February 1932) is a Swedish actress, best known outside Sweden for being part of director Ingmar Bergman's stock company. She often plays impulsive, working class characters. Contents 1 Film actress 2 Awards 3 Private life 4 Selected filmography 5 References 6 Notes 7 External links Film actress Harriet Andersson began her acting career as a 15-year-old student at Calle Flygare stage school. She joined director Ingmar Bergman for several stage productions at Malmö sta...