Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are recursive structural types not supported in scala anymore?

Tags:

scala

Some people claim that scala is able to deal with recursive structural types if you use the -Yrecursion option of scalac. Nevertheless my minimalistic example does not compile:

type Num = {
  def +(n: Num): Num
}

Compilation yields:

$ scalac -version
Scala compiler version 2.8.0.final -- Copyright 2002-2010, LAMP/EPFL
$ scalac -Yrecursion 100 Num.scala 
Num.scala:3: error: recursive method + needs result type
def +(n: Num): Num
               ^
one error found

Did this change? Shouldn't the example compile?

like image 322
gruenewa Avatar asked Aug 12 '10 09:08

gruenewa


1 Answers

Recursive structural types have never been supported. The -Yrecursion option does something unrelated to structural types.

like image 122
Miles Sabin Avatar answered Oct 19 '22 16:10

Miles Sabin