WeakMap better than Private Symbols? (was: direct_proxies "problem")

Allen Wirfs-Brock allen at wirfs-brock.com
Thu Jan 10 09:38:59 PST 2013


On Jan 10, 2013, at 8:41 AM, Brendan Eich wrote:

> Nathan Wall wrote:
>> In the case of (1), the implementation using a private symbol will have internal accesses to the `timestamp` symbol exposed through the unknownPrivateSymbol trap.
> 
> Private symbols do not trap.
> 
>> In the case of (2), the implementation using a private symbol will fail on a call to `setTime` when the object is frozen (I think).
> 
> Nope, we agreed that frozen objects support setting pre-existing (added before the object was made non-extensible) properties named by private symbols.
> 

Yes, indeed.

In addition I'm now thinking we want Object.freeze to notify the object via a @@method it is bering  frozen .  This gives the object an opportunity to configure its private state and public behavior in a manner that actually presents an immutable abstraction.  For example, a collection that holds it elements in a private symbol accessed slot and uses public accessor methods might internally set a flag that makes the collection act immutably.  

Allen



More information about the es-discuss mailing list