简体   繁体   English

“仿制药”和“高阶类型”之间的关系是什么?

[英]What's the relation between “generics” and “higher-order types”?

From this question: What is a higher kinded type in Scala? 从这个问题: Scala中什么是更高级的kinded类型? , I understand what is higher-order types (also first-order type and proper type ). ,我明白什么是higher-order types (也是first-order typeproper type )。

But there is still a question: What's the relation between generics and "higher-order types"? 但仍有一个问题: generics与“高阶类型”之间的关系是什么?

I know Java supports generics , which is like the first-order type in Scala. 我知道Java支持generics ,这就像Scala中的first-order类型。

Which of the following are correct? 以下哪项是正确的?

  1. In Scala, only the first-order type is generics 在Scala中,只有first-order typegenerics
  2. In Scala, first-order and higher-order types are both belong to generics 在Scala中, first-orderhigher-order类型都属于generics
  3. In Java, the generics just mean first-order type, it's not complete 在Java中, generics只是first-order类型,它并不完整
  4. generics is a common term means we can "abstract" on types, no matter first-order or higher-order generics是一个常用术语,意味着我们可以“抽象”类型,无论是first-order还是higher-order

I'd say (1.) is wrong. 我会说(1.)是错的。 I'm not sure about (3.) because I'm a bit out of practice concerning Java. 我不确定(3.)因为我在Java方面有点不合时宜。 But I'd say (4.) is pretty accurate and somewhat similar to (2.). 但我会说(4.)非常准确,有点类似于(2.)。

As far as I know, the term generics refers just to the usage of type parameters. 据我所知, 泛型一词仅指类型参数的用法。 It applies to both first-order and higher-order types or functions. 它适用于一阶更高阶类型或函数。

Offtopic (and somewhat nerdish): Does anyone else see a hidden reference to Wing Commander in (2.) Offtopic(有些神经质):是否有其他人在(2.)中看到Wing Commander的隐藏引用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM