views:

602

answers:

2

A bit more specific than this question, can someone tell me 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.

Edit: 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

+1  A: 

They are supposed to be equivalent, as their main purpose is interacting with Java's wildcards.

Daniel
I've added Martin Odersky's comment to my original question. Reading his response to Bill Venners, it feels as though existential types are not equivalent to wildcards. Certainly, I'm fairly sure I read something a while back essentially puffing that Scala *not* having wildcard types (as it originally didn't) was a positive thing.
oxbow_lakes
Someone has pointed out to me that it was probably puffing the fact that Scala does not have *raw* types
oxbow_lakes
+1  A: 

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

oxbow_lakes
A link to the whole conversation would be most usefull
Marcelo Morales
There wasn't much more other than this
oxbow_lakes