Fast, indexed, foreach over an array, translated to a while loop.
Fast, indexed, foreach over an array, translated to a while loop.
arrayForeachWithIndex(as)((a, i) => println((a, i)))
Translated to:
{ val $array = as var $i = 0 val $len = array.length while ($i < $len) { val $a = array.apply($i) f($a, $i); $i += 1 } }
where the f
is inlined.
Assert that cond
is true.
Assert that cond
is true. The tree of cond
is used as the assertion message.
This call:
This call:
cfor(zero = 0)(okay = _ < 10, next = _ += 2) { println(_) }
Translates to:
val a = zero while (okay(a)) { act(a) a = next(a) }
where the bodies of okay
, next
, and act
are inlined.
the tree of a
after the typer, printed as source code.
Converts:
Converts:
iteratorForeach(iterator)(a => <body>)
To:
while(iterator.hasNext) f(iterator.next())
where f
is inlined.
Automatic lens generation.
Automatic lens generation.
case class Foo(a: Int) val l = lens[Foo].a val foo = Foo(0) l._1(foo) // 0 l._2(foo, 1) // Foo(1)
log("".isEmpty) // prints: "".isEmpty = true
log("".isEmpty) // prints: "".isEmpty = true
Statically checked version of "some([Rr]egex)".r
.
Statically checked version of "some([Rr]egex)".r
.
Invalid regular expressions trigger a compile failure.
At runtime, the regex is parsed again.
scala> regex(".*") res0: scala.util.matching.Regex = .* scala> regex("{") <console>:11: error: exception during macro expansion: Illegal repetition { regex("{") ^
Trace execution on c
, by printing the values of sub-expressions
to standard out.
Trace execution on c
, by printing the values of sub-expressions
to standard out.