From: Jean Privat Date: Tue, 22 Jul 2014 17:26:27 +0000 (-0400) Subject: Merge: Add annotation lazy on attributes X-Git-Tag: v0.6.7~30 X-Git-Url: http://nitlanguage.org 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 Reviewed-by: Lucas Bajolet --- 4d45ba36d4b8be7d44c2a854b96d51b0a1445006