manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.38k stars 125 forks source link

[Feature Request] lazy @val properties #599

Open EotT123 opened 4 months ago

EotT123 commented 4 months ago

Could it be possible to add lazy initialized fields when using properties? (similar to Lombok's @Getter(lazy=true)

The same syntax could be used, e.g. @val(lazy = true) Object object = <ExpensiveCalculation>;. This should only be added for @val (not for @var,@set,...), as it is only relevant for immutable fields.

rsmckinney commented 4 months ago

I am probably going to expand properties to support observable, delegation, lazy etc. a la Kotlin. See https://github.com/manifold-systems/manifold/issues/256.