What is a “First Class” type?

后端 未结 3 1579
故里飘歌
故里飘歌 2020-12-24 06:56

What does it mean for a type T to be a \"First Class\" type?

3条回答
  •  礼貌的吻别
    2020-12-24 07:28

    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.

提交回复
热议问题