Security Demands Simplicity (was: Private Slots)

Kevin Smith khs4473 at
Thu Jan 17 13:40:49 PST 2013

> 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 -

{ Kevin }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list