First Class Type

来源:互联网 发布:哪些明星开了淘宝店铺 编辑:程序博客网 时间:2024/05/17 08:53

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.

 

??????


0 0
原创粉丝点击