klauso/SLE2013 — pull request #2 by b-studios (2014-03-02 14:52:33+00:00)
Title: Prevent initialization bugs

I am not sure whether this is important enough to be included in the lecture notes, but using `val` here can cause initialization problems (access to `symMap` to early causes `null` pointer exception).

The problem occurred when executing

~~~scala
trait MyLanguage extends Integers with Convs
trait MyLanguageExp extends MyLanguage with IntegersExp with ConvsExp
trait testProgram { self: MyLanguage =>
val x: Rep[Int] = lift(42) + lift(1) * 3
}
object test extends testProgram with MyLanguageExp
~~~

~~~text
java.lang.NullPointerException
at BaseExp$class.findOrCreateDefinition
at test$.findOrCreateDefinition
at BaseExp$class.toAtom
at test$.toAtom
at IntegersExp$class.mult
~~~

Instead using `lazy val` fixes the problem, since it provide means for initialization order independence.