First Class Type

Swift中關於函數有這樣的介紹

Functions are a first-class type. This means that a function can return another function as its value.

函數是先類類型?意味着一個函數可以將另一個函數當作它的返回值返回。

看看 stackoverflow上關於這個的解釋

Usually it means instances of T can be

  • returned from functions
  • passed into functions
  • constructed at runtime

Eg functions in C are not first class types as they cannot be constructed at runtime, but they are in JavaScript.

In some specialised circumstances, for example theorem proving, it means that types themselves are first class objects. More modern literature uses 'reified types' instead to denote this to avoid such ambiguity.

 

??????


發佈了137 篇原創文章 · 獲贊 8 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章