Why won’t the Scala compiler apply tail call optimization unless a method is final?
Consider the following interaction with the REPL. First we define a class with a factorial method: scala> class C { def fact(n: Int, result: Int): Int = if(n == 0) result else fact(n – 1, n * result) } defined class C scala> (new C).fact(5, 1) res11: Int = 120 Now let’s override it in … Read more