Conversation
|
I am curious how this will develop, is the goal to support some subset of recursion if the iteration condition can be proven to reach a base case? |
Yes, exactly. We will start with direct structural recursion on inductive types. For example, recursion on a sub-list: def sum(l: List[Int]): Int =
l match
case Nil => 0
case x :: xs => x + sum(xs) // xs is strictly smaller than lLater, we could extend this to more general patterns, such as mutual recursion or recursion on numeric arguments. The main motivation is integration with refinement types. We will need termination guarantees for definitions that appear in erased proofs in order to preserve soundness. |
|
Failing test: You will probably need to add a filter in there: scala3/project/MiMaFilters.scala Lines 8 to 19 in f302695 |
How do you tell if these is any recursion and check it statically? |
In recursive calls, at least on argument should decrease, and all others should be nonincreasing. An argument is decreasing if it is a case class whose `unapply` method is not overridden, whose fields are immutable and the recursive call is on a subpart of it.
d0286d3 to
83fd276
Compare
Termination Checking
The goal of this PR is to introduce a termination checker phase for the functional subset of Scala.
Currently,
CheckTerminationcompiler phase, which forbids all recursive calls.@terminatesfunction annotation.-Ycheck-terminationcompiler flag.Additional notes
This is an EPFL Research Project supervised by @mbovel.