Updated State of the Specialization

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Fri Dec 19 23:53:39 UTC 2014


As long as I know, we currently have List<E> and We try to specialize (or
any-fy) that.
How your solution handle List<int> case?


On Sat, Dec 20, 2014 at 2:15 AM, Timo Kinnunen <timo.kinnunen at gmail.com>
wrote:
>
> Hi,
>
>
> I’m not sure Peeling is necessary. The reason is that the problem it’s
> trying to solve already exists in the current Java and it has workarounds
> too. Here’s a demonstration with three ListLike<T> adaptations and the
> workarounds:
>
>
> interface SmallList<T> {
>
> public void remove(short position);
>
> public void remove(T element);
>
> }
>
> interface MediumList<T> {
>
> public void remove(int position);
>
> public void remove(T element);
>
> }
>
> interface BigList<T> {
>
> public void remove(BigInteger position);
>
> public void remove(T element);
>
> }
>
>
> public class Workaround {
>
> @SuppressWarnings({ "rawtypes", "unchecked" })
>
> static void method(SmallList<Short> smallList, MediumList<Integer>
> mediumList, BigList<BigInteger> bigList) {
>
>
> smallList.remove((short) 3);
>
> smallList.remove((Short) (short) 3);
>
>
> mediumList.remove(3);
>
> mediumList.remove((Integer) 3);
>
>
> ((BigList<?>) bigList).remove(BigInteger.valueOf(3));
>
> ((BigList) bigList).remove((Object) BigInteger.valueOf(3));
>
> }
>
> }
>
>
> For the record, none of the workarounds feel “correct” to me, although the
> int/Integer pair gets close.
>
>
> Rather than Peeling, what I think is needed is to streamline overload
> selection so that the specialized methods are selected whenever possible
> and the non-specialized methods can be manually selected with extra casts,
> like this:
>
>
>
> smallList.remove((short) 3);
>
> smallList.remove(3);
>
>
>
>
> mediumList.remove((int) 3);
>
> mediumList.remove(3);
>
>
>
>
> bigList.remove((BigInteger) BigInteger.valueOf(3));
>
> bigList.remove(BigInteger.valueOf(3));
>
>
>
>
> --
> Have a nice day,
> Timo.
>
> Sent from Windows Mail
>
>
>
>
>
> From: Brian Goetz
> Sent: ‎Friday‎, ‎December‎ ‎19‎, ‎2014 ‎22‎:‎31
> To: valhalla-dev at openjdk.java.net
>
>
>
>
>
> I've updated the State of the Specialization here:
>    http://cr.openjdk.java.net/~briangoetz/valhalla/specialization.html
>
> The old version is here:
>    http://cr.openjdk.java.net/~briangoetz/valhalla/specialization-1.html
>


More information about the valhalla-dev mailing list