To me decorators are the answer to pretty much everything but for the last
year I've seen zero progress on what seems to be a forever Stage 2
proposal: https://github.com/tc39/proposals#stage-2

Is there anything anyone can do to speed up adoption/implementation of that
proposal?

On Tue, Jun 12, 2018 at 4:24 PM, Augusto Moura <augusto.borg...@gmail.com>
wrote:

> I don't think a new keyword is the right path here. For classes lazy
> fields can easily be implemented via decorators in the last proposal[1]
> (also, Groovy has previous work implementing a `@Lazy` annotation[2] with
> AST transformations for the same use case). In code something like:
> ``` js
> const lazy = (fieldMetadata) => {
>   // change the field value in descriptor to a lazy factory
> };
>
> class Foo {
>
>   @lazy bar = slowCalculation();
>
>   @lazy statements = (() => {
>      if (this.bar > 0) {
>        return fooify();
>      } else {
>        return barify();
>      }
>   }());
>
> }
> ```
>
> What it's doesn't cover (and in my opinion should be the focus of a new
> proposal) is Decorators for literal objects. Something like the code below
> is yet not proposed:
>
> ``` js
> const foo = {
>   @lazy bar: 3,
> };
> ```
>
> I didn't made a deep search in ESDiscuss history but I remember this
> feature being mentioned sometime ago.
>
> [1]: https://github.com/tc39/proposal-decorators
> [2]: http://groovy-lang.org/metaprogramming.html#xform-Lazy
> --
> Augusto Moura
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to