Use cases for WeakMap
brendan at mozilla.com
Mon May 16 00:25:08 PDT 2011
On May 16, 2011, at 12:18 AM, Erik Corry wrote:
> 2011/5/16 Brendan Eich <brendan at mozilla.com>:
>> On May 16, 2011, at 12:01 AM, Brendan Eich wrote:
>>> On May 15, 2011, at 11:55 PM, Erik Corry wrote:
>>>> 2011/5/16 Brendan Eich <brendan at mozilla.com>:
>>>>> Not if the object is frozen.
>>>> That shouldn't prevent you adding private names. See earlier message
>>>> in this thread.
>>> Frozen means [[Extensible]] is false, so you can't add any properties, ...
>> I'll go further: frozen means the implementation should be free to move the object and anything associated with its shallow-frozen key/value state into read-only memory, so the full force of 50-year-plus OS and hardware MMU protection can ensure [[Extensible]] really is false.
> I think this would also preclude the most efficient implementation of
> Weak Maps. In fact I have a hard time seeing how you would GC weak
> maps at all under these conditions.
Why, because GC metadata has to go in the same page as the frozen object that might be a key in a weak map?
Weak maps are in Firefox nightlies. We're playing with page protection too (not for freezing, yet). This seems like a dare, but it also seems to be dodging my point in replying again: that private names cannot be used to extend frozen objects in the "[[Extensible]] = true" sense of the spec.
More information about the es-discuss