>
> The Ephemeron gc technique
> contributes nothing to the ability to reclaim space for such code
> because of the relative lifetimes of the map and its keys.
>

Yes - my line-of-thought as well.  If I may riff on your code a bit (ymmv):

    class Purse {

        // Move private field declaration out here for more scopy-ness
        private balance;

        // Allow private without arg as shorthand for "private(this)"
        constructor(balance = 0) { private.balance = balance; }

        // Everything else the same
        getBalance() { return balance; }
        makePurse() { return new Purse; }
        deposit(amount, srcPurse) {
            private(srcPurse).balance -= amount;
            balance += amount;
        }
    }

The expansion is exactly the same, except that the private record is sealed
before the constructor body starts executing.  Reconceptualizing private
instance state in terms of a separate object stored in a weakmap -
interesting!

{ Kevin }
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to