I understand the class rationale, but the lack of symmetry over mult is confusing as an end result.
brianThu 2 Oct 2008
I agree it isn't ideal, but is really because of two independent features interacting together:
i*num => i.mult(num) => i.mult((Int)num)
So the * shortcut turns into the normal mult method. Then the auto-cast feature doesn't force you to insert the manual Int cast.
So there is really only Int.mult(Int). Num doesn't have a mult method, since we'd have to support contra-variance to efficiently limit Int.mult to only take an Int.
Fan doesn't have the numerical tower like scheme languages.
alexlamslThu 2 Oct 2008
Just to add that not all number systems are commutative and associative for addition and multiplication ;-)
f00biebletch Thu 2 Oct 2008
Given
Why does the following compile:
while the following does not:
I understand the class rationale, but the lack of symmetry over mult is confusing as an end result.
brian Thu 2 Oct 2008
I agree it isn't ideal, but is really because of two independent features interacting together:
So the * shortcut turns into the normal
mult
method. Then the auto-cast feature doesn't force you to insert the manualInt
cast.So there is really only
Int.mult(Int)
. Num doesn't have amult
method, since we'd have to support contra-variance to efficiently limitInt.mult
to only take anInt
.Fan doesn't have the numerical tower like scheme languages.
alexlamsl Thu 2 Oct 2008
Just to add that not all number systems are commutative and associative for addition and multiplication ;-)