On Wed, Aug 29, 2012 at 9:51 PM, iulian dragos <
jagu...@gmail.com> wrote:
> That would be much better.
Since this was easy to do, I tried it out. The value of value classes... the two representations of "calc" in the following differ only in whether the various referenced classes extend AnyVal.
def calc(x: Meter, y: Double): MetersSquared = x * y.km
public double calc(double, double);
0: dload_3
1: sipush 1000
4: i2d
5: dmul
6: dstore 5
8: dload_1
9: dload 5
11: dmul
12: dreturn
public scala.MetersSquared calc(scala.Meter, double);
0: new #31; //class scala/foo$MeterOps
3: dup
4: dload_2
5: invokespecial #34; //Method scala/foo$MeterOps."<init>":(D)V
8: astore 4
10: new #36; //class scala/Kilometer
13: dup
14: aload 4
16: invokevirtual #40; //Method scala/foo$MeterOps.value:()D
19: invokespecial #41; //Method scala/Kilometer."<init>":(D)V
22: astore 5
24: new #43; //class scala/Meter
27: dup
28: aload 5
30: invokevirtual #44; //Method scala/Kilometer.value:()D
33: sipush 1000
36: i2d
37: dmul
38: invokespecial #45; //Method scala/Meter."<init>":(D)V
41: astore 6
43: new #47; //class scala/MetersSquared
46: dup
47: aload_1
48: invokevirtual #48; //Method scala/Meter.value:()D
51: aload 6
53: invokevirtual #48; //Method scala/Meter.value:()D
56: dmul
57: invokespecial #49; //Method scala/MetersSquared."<init>":(D)V
60: areturn