Also, some implementation notes (any help or advice for making a better implementation than my proof of concept would be good). Right now it's implemented by having the parser transform anonymous functions to case clauses: fun(lhs => rhs) becomes fun({case lsh => rhs}). I think this is generally the right way to do it, but my implementation takes snapshots of the scanner's position and jumps around in it rather than really integrating it in to the syntax. I also have a hack to ignore a bunch of files that it has problems with (the type inference and bracket problems below)
Type inference seems a bit weaker when using case clauses rather than normal anonymous functions. For example,
List(1, 2, 3).reduceLeft((a, b) => a + b) //compiles
List(1, 2, 3).reduceLeft{case (a, b) => a + b} //doesn't compile, needs a type annotation:
List(1, 2, 3).reduceLeft[Int]{case (a, b) => a + b} //compiles
This causes some code to not compile after my transformation since it would need type annotations, unless there's some way to fix this.
Finally, I think there might be a syntax change that needs to be made. I didn't put it in the draft because I'm not sure if it's just a problem with my implementation.
When defining functions in an anonymous function, you need extra brackets when using the {case ...} notation rather than the normal function notation:
class ControlContext[A,B,C](val fun: (A => B, Exception => B) => C, val x: A)
new ControlContext((f: Int => Double, e: Exception => Double) => "a", 2) //compiles
but putting exactly that in a case block doesn't compile:
new ControlContext({case (f: Int => Double, e: Exception => Double) => "a"}, 2) //doesn't compile
not only do you need type annotations for this (because of the weaker type inference?), but the two function type annotations "Int => Double" and "Exception => Double" need to be wrapped in brackets:
new ControlContext[Int, Double, String]({case (f: (Int => Double), e: (Exception => Double)) => "a"}, 2) //compiles
These two problems come up in a few dozen places in the scala compiler / library, so I have excluded these from using my change (see "val ignoredFiles" in Parsers.scala for the list). If you comment them out and remove "build" plus all the generated jars, you can see the errors when you build. You can also see the diff for ControlContext.scala and AnnotationInfos.scala for changes that can be made to the source code to work around it.
I'm hoping that these are both fixable with a better implementation of the change.