Consider this code:
Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array(Array())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
I aborted the REPL after several minutes.
Should I expect such long compilation times or is this a problem/bug of the compiler?
Misleading title, I think, at least with respect to the actual code you're trying.
Let's help the type inferencer...
object A extends App {
val x = Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Array[Nothing]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]()
println(x)
}
That compiles just fine and runs just fine (I don't even have to modify JVM options):
$ time scalac -d classes A.scala
real 0m5.179s
$ time scala -cp classes A
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[Ljava.lang.Object;@872380
real 0m2.461s
So it's more about compilation and type inference including in the REPL (which rewrites the code and recompiles). The REPL seems to struggle somewhere after the explicitrouter phase (tried using scala -Xprint:all
).
On Scala 2.9.0.1 this compiles (and runs) just fine as long as you give scalac enough stack space:
export JAVA_OPTS="-ss128M"
scalac arrays.scala
It doesn't seem to work in the REPL though, but that doesn't really surprise me anymore...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With