Scala的存在类型和Java的通配符之间的区别是什么? [英] Difference between Scala's existential types and Java's wildcard by example?

查看:134
本文介绍了Scala的存在类型和Java的通配符之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比Stack Overflow问题更具体 什么是存在类型? ,Scala的存在类型和Java的通配符之间有什么区别,特别是有一些说明性的例子?

A bit more specific than Stack Overflow question What is an existential type?, what is the difference between Scala's existential types and Java's wildcard, prefereably with some illustrative example?

在我到目前为止看到的所有内容中,它们似乎相当。

In everything I've seen so far, they seem to be pretty equivalent.

A很少参考。 Martin Odersky 提及他们;谷歌的我的问题最受欢迎

A few references. Martin Odersky mentions them; Google's top hit for my question:


MO:原始通配符设计......受到存在类型的启发。实际上,原始论文在存在类型中具有编码。但是当实际的最终设计出现在Java中时,这种连接有点丢失

MO: The original wildcard design ... was inspired by existential types. In fact the original paper had an encoding in existential types. But then when the actual final design came out in Java, this connection got lost a little bit


推荐答案

<这是Martin Odersky对Scala用户邮件列表的回答:

This is Martin Odersky's answer on the Scala-users mailing list:


原始Java通配符类型(如ECOOP文件中所述)
Igarashi和Viroli)确实只是存在主义
类型的缩写。我被告知并且我已经阅读了FOOL '05关于Wild FJ的论文,其中
通配符的最终版本与
存在类型有一些细微差别。我不确切地知道在什么意义上(他们的
形式主义与经典的存在主义类型相差太远,无法确定差异),但也许仔细阅读Wild
FJ论文会对它有所了解。

The original Java wildcard types (as described in the ECOOP paper by Igarashi and Viroli) were indeed just shorthands for existential types. I am told and I have read in the FOOL '05 paper on Wild FJ that the final version of wildcards has some subtle differences with existential types. I would not know exactly in what sense (their formalism is too far removed from classical existential types to be able to pinpoint the difference), but maybe a careful read of the Wild FJ paper would shed some light on it.

所以看起来Scala存在类型和Java通配符似乎是等价的

So it does seem that Scala existential types and Java wildcards are kind-of equivalent

这篇关于Scala的存在类型和Java的通配符之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆