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)
commit4d45ba36d4b8be7d44c2a854b96d51b0a1445006
treed757378407fc237752e346ae602a83f2c0424662
parentcf5552e2b7b0ffa0b6f5859968ff64c2dd88ff7f
parentd59f99ff23c55cd5a016757ff56e799bc8c4e0c2
Merge: Add annotation lazy on attributes

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>