Scala API docs for 2.10.3 say I can: "Use refiy to create an abstract syntax tree representing this Scala expression." Accordingly, I can do:
scala> val uni = scala.reflect.runtime.universe uni: scala.reflect.api.JavaUniverse = scala.reflect.runtime.JavaUniverse@4e42766 scala> uni reify { 1 to 3 } res2: uni.Expr[scala.collection.immutable.Range.Inclusive] = Expr[scala.collection.immutable.Range.Inclusive](Predef.intWrapper(1).to(3))
In the above example, I get what I am looking for: Predef.intWrapper(1).to(3)) (a convenient extended representation of the operations that need to be performed).
When I try to confirm 1 + 3 , however, I cannot imagine the execution of the operations that I desire.
scala> uni reify { 1 + 3 } res5: uni.Expr[Int(4)] = Expr[Int(4)](4)
Is this the expected behavior? Is + primitive operation and therefore not reified?
Scala docs show an example of reification, which assumes an even more useful view is available:
reify{ 2 + 4 } // Apply( Select( Literal(Constant(2)), newTermName("$plus")), List( Literal(Constant(4)) ) )
How can I check the correct extended view for 1 + 3 (if it exists) and how can I get a detailed view of any expression (immediately above)?
Edit: Now I see that the view in the Scala showRaw is being created by showRaw . However, I still cannot reproduce the raw view in the example above for 2 + 4 .
source share