Merge: Add annotation lazy on attributes
authorJean Privat <jean@pryen.org>
Tue, 22 Jul 2014 17:26:27 +0000 (13:26 -0400)
committerJean Privat <jean@pryen.org>
Tue, 22 Jul 2014 17:26:27 +0000 (13:26 -0400)
This annotation is basically a better `cached`.

~~~
class A
   var foo: Foo = some_complex_computation is lazy
end
var a = new A # no complex computation done yet
print a.foo # complex computation is done here
~~~

Unlike cached, the attribute is visible, and if a setter is available, the lazy can be sortcut. Thus lazy is behaving like a default value.

~~~
var b = new A
b.foo = new Foo # set before get,
print b.foo # thus complex computation is never done!
~~~

Note that with `readonly` #604 the setter can be unavailable, thus having lazy the only way to initialyze attributes.

Pull-Request: #605
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>


Trivial merge