The EmbeddedControls trait provides method definitions where
calls to the methods are treated by the compiler in a special way.
The reason to express these calls as methods is to give embedded
DSLs a chance to provide their own definitions and thereby override
the standard interpretation of the compiler.
Example: When faced with an if construct, the @virtualized
macro annotation will generate a method call:
ifThenElse(cond, thenp, elsep)
This method call will be bound to an implementation based on normal
rules of scoping. If it binds to the standard one in this trait,
the corresponding macro will replace it by an If tree node. If
not, the call will be left as it is and a staging or interpreting
DSL can take over.
Note
None of the above will happen unless you annotate your code with @virtualize.
Default implementation of virtualized Scala control structures.
This trait is adapted from the
EmbeddedControls
trait in Scala Virtualized. See also https://raw.github.com/namin/scala/topic-virt/src/library/scala/EmbeddedControls.scalaThe
EmbeddedControls
trait provides method definitions where calls to the methods are treated by the compiler in a special way. The reason to express these calls as methods is to give embedded DSLs a chance to provide their own definitions and thereby override the standard interpretation of the compiler.Example: When faced with an
if
construct, the@virtualized
macro annotation will generate a method call:ifThenElse(cond, thenp, elsep)
This method call will be bound to an implementation based on normal rules of scoping. If it binds to the standard one in this trait, the corresponding macro will replace it by an
If
tree node. If not, the call will be left as it is and a staging or interpreting DSL can take over.None of the above will happen unless you annotate your code with
@virtualize
.