TCO

Scalaって末尾再帰の最適化してるの? - みずぴー日記
をねまーるでまねーる。

def fact(n){
  | 0 => 1
  | _ => n * fact(n - 1)
}
fact(1000000)
Process is terminated due to StackOverflowException.
def fact_i(n){
  def loop(m, n){
    | (_, 0) => 1
    | _ => loop(n * m, n - 1)
  }
  loop(1, n)
}
fact_i(1000000)
ハンドルされていない例外: System.OverflowException: 算術演算の結果オーバーフローが発生しました。
   場所 fact_i.Main()

うむ。

+

SOEとかOEをcatchできないのは仕様?