Fwd: Remi's comments on Any

Gavin King gavin at hibernate.org
Mon Jan 5 14:21:25 UTC 2015


>> On Mon, Jan 5, 2015 at 12:27 PM, Remi Forax <forax at univ-mlv.fr> wrote:

>> When I'm saying we don't necessarily need to let you write:
>>
>>      ArrayList<Any> list = new ArrayList<Any>();
>>
>> I'm not saying we don't need to let you write:
>>
>>      ArrayList<? extends Any> list = new ArrayList<int>();
>>
>> I don't understand how you're proposing to write this second example.
>
>
> ArrayList<? extends Object> list = new ArrayList<int>().boxed();

Right, which means we're still making the generic type system of Java
more weird instead of more regular. Generics are already much too
complicated without more extra weird stuff.

I understand that the folks who have to implement this stuff on the VM
are naturally looking for the thing that is simplest to implement. But
if that ease of implementation surfaces itself as extra complexity in
the type system, I don't think it does anyone a favor.

> no, it's the opposite, value type can be implemented as a JIT only
> optimisation
> (if you forget data structure specialization) by example, the change is not
> as pervasive as Any.

Well, OK, I'll have to take your word for it, but I still think it
might be worth doing. All this specialization stuff in principle lets
statically typed languages avoid boxing on the JVM. It doesn't help
dynamically typed languages, AFAICS.


-- 
Gavin King
gavin.king at gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org


More information about the valhalla-dev mailing list