Skip to content

Instantly share code, notes, and snippets.

@mpilquist
Created July 30, 2015 01:55
Show Gist options
  • Save mpilquist/4ed3196e9ee4543c1847 to your computer and use it in GitHub Desktop.
Save mpilquist/4ed3196e9ee4543c1847 to your computer and use it in GitHub Desktop.
Using scala-reflect to desugar
scala> import scala.reflect.runtime.universe._
import scala.reflect.runtime.universe._
scala> showCode(reify {
| for{
| x <- 1 to 5
| _ = print("hi")
| } print(x)
| }.tree)
res1: String =
Predef.intWrapper(1).to(5).map(((x) => {
val x$1 = Predef.print("hi");
Tuple2.apply(x, x$1)
}))(IndexedSeq.canBuildFrom).foreach(((x$2) => (x$2: @unchecked) match {
case Tuple2((x @ _), _) => Predef.print(x)
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment