~/scala-library/scala javap Tuple2\$mcII\$sp.classCompiled from "Tuple2.scala"public class scala.Tuple2$mcII$sp extends scala.Tuple2<java.lang.Object, java.lang.Object> implements scala.Product2$mcII$sp { public final int _1$mcI$sp; public final int _2$mcI$sp; public int _1$mcI$sp(); public int _1(); public int _2$mcI$sp(); public int _2(); public scala.Tuple2<java.lang.Object, java.lang.Object> swap(); public scala.Tuple2<java.lang.Object, java.lang.Object> swap$mcII$sp(); public <T1, T2> int copy$default$1(); public <T1, T2> int copy$default$1$mcI$sp(); public <T1, T2> int copy$default$2(); public <T1, T2> int copy$default$2$mcI$sp(); public boolean specInstance$(); public java.lang.Object copy$default$2(); public java.lang.Object copy$default$1(); public java.lang.Object _2(); public java.lang.Object _1(); public scala.Tuple2$mcII$sp(int, int);}
scala.Tuple2$mcII$sp object internals: OFFSET SIZE TYPE DESCRIPTION VALUE 0 4 (object header) 01 00 00 00 (0000 0001 0000 0000 0000 0000 0000 0000) 4 4 (object header) 00 00 00 00 (0000 0000 0000 0000 0000 0000 0000 0000) 8 4 (object header) 05 c3 00 f8 (0000 0101 1100 0011 0000 0000 1111 1000) 12 4 Object Tuple2._1 null 16 4 Object Tuple2._2 null 20 4 int Tuple2$mcII$sp._1$mcI$sp 1 24 4 int Tuple2$mcII$sp._2$mcI$sp 2 28 4 (loss due to the next object alignment)Instance size: 32 bytes (reported by Instrumentation API)Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
Does scala uses the specialized version of Tuple2 class is Tuple(2, 2) involved? If that's true, how does the superclass's fields are not taken into account?
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Actually, it's not a fundamental limitation of the "whole" approach, just a consequence of a particular decision: do you promise vals or not? If _1, _2, etc. were defs in Tuple, then the specialized versions would just forward-and-box when used in a non-specialized context. There is an efficiency argument for vals if Tuple allows inheritance, but the decision has already been made not to in the future, at which point _1 and _2 can be defs, and even the present specialization could save space.
Exactly, and you then count on the JVM to hide the difference, which it is pretty good at. It's not obviously a better choice, but it is a possible choice.
Cheers,Vlad