given def OptiML[R](b: => R) = new Scope[OptiML, OptiMLExp, R](b)
given def OptiML[R](b: => R) = new Scope[OptiML, OptiMLExp, R](b)
OptiML { body }
is expanded to:
trait DSLprog$ extends OptiML { def apply = body } (new DSLprog$ with OptiMLExp): OptiML with OptiMLExp
Struct is a marker trait used to indicate that new C { ... }
should be reified.
Struct is a marker trait used to indicate that new C { ... }
should be reified.
Selections on the result e
of the reified object creation, e.x_i
,
are treated specially, as outlined below.
If there's a type constructor Rep
(of kind * -> *
) so that C <:< Struct
,
the expression new C { (val x_i: T_i = v_i)* }
is turned into
the call new(("x_i", (self_i: Rep[C{ (val x_i: T_i')* }]) => v_i')*)
,
which is typed with expected type
Rep[C{ (val x_i: T_i')* }]
For all i,
this
by a fresh variable self_i
(with type Rep[C{ (val x_i: T_i')* }]
)This assumes there is a method in scope similar to: def new[T](args: (String, Rep[T] => Rep[_])*): Rep[T]
When a selection e.x_i
does not type check according to the normal typing rules,
and e
has type Rep[C{ (val x_i: T_i')* }]
(where C
meets the criteria outlined above),
e.x_i
is turned into e.selectDynamic[T_i]("x_i")
Note why types are by-value
Returns string formatted according to given format
string.
Returns string formatted according to given format
string.
Format strings are as for String.format
(@see java.lang.String.format).
The
EmbeddedControls
object 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 faces with an
if
construct, the parser will generatea 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 type checker 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.