4 ms·
That's why I said: > Most of it is supported in Scala scalac does not use trampolining. It rewrites tail-recurisve calls into “loops” (or jumps if you look at
by soc88 15y ago
That's why I said:
> Most of it is supported in Scala
scalac does not use trampolining. It rewrites tail-recurisve calls into “loops” (or jumps if you look at the bytecode).
This is a case where the JVM lacks the necessary feature.
There are experiments with value classes in Scala, which might allow you to use arrays of primitive numbers for them, but currently it looks like it won't happen for 2.10 because it can't be made work good enough in some corner cases like reflection, toString, equality, ...
- rbehrends 15y agoNo, Scala cannot optimize all forms of tail recursion (such as mutually tail-recursive functions). In that case, you have to use scala.util.control.TailCalls to do it via trampolines. The proposed value classes in Scala do not solve the overhead problem for complex numbers. As specified in SIP-15, they have exactly one field, and basically are designed to give you information hiding for classes with a single field without boxing overhead. Edit: By the way, you don't have to sell me on Scala. I have been using it since 1.x (I have forgotten the exact version number).
- soc88 15y agoSorry, if I appeared as I tried to sell you something. > No, Scala cannot optimize all forms of tail recursion (such as mutually tail-recursive functions). In that case, you have to use scala.util.control.TailCalls to do it via trampolines. I guess we are just nick-picking each other here. :-) I think be both understand what the compiler can do, cannot do, what it does automatically and what not. Have you seen the Complex implementation which uses an underlying Long as Floats? (Sounds ugly but seems to work quite nicely.) The biggest problem at the moment is putting value types in an array. Currently it seems like some ugly clutch/work-around ill be used. I hope SIP-15 gets either rejected or delayed until there is a better solution, Because the difference between an array of references and an array of primitives really matters imho.