[proposal] Persistent variables in functions/methods
Jacob Pratt
jhprattdev at gmail.com
Tue Jul 17 05:17:17 UTC 2018
> If it “belongs” inside a function, then it should “live” inside function
body `{ }`
Agreed, but these values don't live _inside_ the function, but rather
_alongside_ the function. If it were inside, it would share the lifetime
with the function call (which it doesn't).
jhpratt
On Tue, Jul 17, 2018 at 1:14 AM, Neek Sandhu <neek.sandhu at outlook.com>
wrote:
> It’d work but won’t be beautiful. With this proposal, code would be much
> easier to reason about.
>
>
>
> Also it breaks encapsulation (logical, semantic and syntactic), stuff
> should live where it belongs. If it “belongs” inside a function, then it
> should “live” inside function body `{ }`
>
>
>
> In the same context, notice how we evolved from callbacks to Promises and
> now to async/await shorthands.
>
>
>
> ```javascript
>
> const res = await fetch('http://example.com')
>
> ```
>
>
>
> More pretty than
>
>
>
> ```javascript
>
> fetch('http://example.com')
>
> .then(res => /* impl */)
>
> ```
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180717/900fd50c/attachment.html>
More information about the es-discuss
mailing list