Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Scala's existential types and Java's wildcard by example?

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 few references. Martin Odersky mentions them; Google's top hit for my question:

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

like image 941
oxbow_lakes Avatar asked Jun 23 '09 07:06

oxbow_lakes


1 Answers

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

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.

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

like image 130
oxbow_lakes Avatar answered Sep 22 '22 13:09

oxbow_lakes