Remi's comments on Any

Thomas W twhitmore.nz at gmail.com
Mon Jan 5 01:08:46 UTC 2015


Thanks Remi.

> The second major problem is how to implement it.
> It can be implemented as a compiler fiction only like in C# or in Scala,
> but in that case apart that one can write ArrayList<int>, it will
> rely on a form of boxing.

I am very happy to disregard the "tagged union" approach & not actually
implement an Any primitive in the VM.

But what if we introduce Any as a 'nominal' type in the type-system, but
implemented as a reftype/ or boxed object with equals() and hashCode()
methods. That would give us the exact same performance of today for
unspecialized code, but a better type-system to describe ArrayList<int>
descending from ArrayList<Any>.

Would that help us?

I am _totally_ happy with reftypes & boxing as our base case, only code
which has been specialized is expected to perform better, performance on
List<Object> is not at issue.

I understand that, both in regard of API & member types (especially array
members), we will actually need to transform or derive a separate version
of the class. I don't believe we can get away from that;  that's why it's
called "specialization".

     ArrayList<int>.class != ArrayList<Object>class


Regards,
Thomas Whitmore


More information about the valhalla-dev mailing list