[proposal] Persistent variables in functions/methods

Neek Sandhu neek.sandhu at outlook.com
Tue Jul 17 05:30:44 UTC 2018

> RE at jhpratt

Well that’s the proposal. In case there’s a confusion with “lifetime”. What I meant was that as far as garbage collector is concerned, persistent variables live as long as the function is referenced somewhere (unlike anonymous functions)

Also revisiting your idea of using static properties instead, how’d you imagine static props on methods of classes considering the fact that stuff should “live” where it “belongs” and not “leak” out unnecessarily, imagine this:

class DBService {
    foo(uri) {
        persist const httpRE = /^https?/;
        persist let counter = 0;

        return 0;

In the example above it is given that no other method in `DBService` class uses, or has anything to with `counter` “inside” of `DBService#foo`. So “leaking” it out is unnecessary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180717/30b261d3/attachment-0001.html>

More information about the es-discuss mailing list