Mark S. Miller (2015-06-17T18:35:15.000Z)
On Wed, Jun 17, 2015 at 11:19 AM, Yusuke SUZUKI <utatane.tea at gmail.com>
wrote:

> It turns out the spec is fine <
>> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-weakmap.prototype.set>
>> step 5 says
>>
>> If Type
>> <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-data-types-and-values>
>> (*key*) is not Object, throw a *TypeError* exception.
>>
>>
>> as I hoped and expected. The reason I was alarmed is that I got the
>> following behavior on v8/iojs:
>>
>> > var w = new WeakMap();
>> undefined
>>
>> > var r = Symbol.for('foo');
>> undefined
>>
>> > w.set(r, true);
>> {}
>>
>> > w.get(r)
>> true
>>
>>
>> I will file a v8 bug. Please someone, add a test for this to test262.
>>
>>
> Ah, I see.
>
> FYI (you may know deeper than I ;)), since symbols are primitive values,
> they cannot be used as a WeakMap's key.
> And since they are primitive values, they cannot have any properties. It
> means that primitive values are immutable.
> So Symbol.for / Symbol.keyFor's registry can be WeakMap in the internal
> implementation.
>
> Actually, we implemented so :D http://trac.webkit.org/changeset/182915
>


Yes, the important issue is the precondition in your "since" statement,
which v8 currently violates.

What do other browsers currently do?


By your observation at the start of this thread, we logically could have
specified that Symbols could be used as WeakMap keys as long as the WeakMap
held them strongly. Needless to say, I am glad we didn't ;).



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150617/84dd7511/attachment.html>
d at domenic.me (2015-07-07T01:42:04.653Z)
On Wed, Jun 17, 2015 at 11:19 AM, Yusuke SUZUKI <utatane.tea at gmail.com> wrote:

> FYI (you may know deeper than I ;)), since symbols are primitive values,
> they cannot be used as a WeakMap's key.
> And since they are primitive values, they cannot have any properties. It
> means that primitive values are immutable.
> So Symbol.for / Symbol.keyFor's registry can be WeakMap in the internal
> implementation.
>
> Actually, we implemented so :D http://trac.webkit.org/changeset/182915


Yes, the important issue is the precondition in your "since" statement,
which v8 currently violates.

What do other browsers currently do?

By your observation at the start of this thread, we logically could have
specified that Symbols could be used as WeakMap keys as long as the WeakMap
held them strongly. Needless to say, I am glad we didn't ;).