typed objects and value types
Dmitry Lomov
dslomov at chromium.org
Wed Apr 2 12:11:50 PDT 2014
On Wed, Apr 2, 2014 at 8:26 PM, Mark S. Miller <erights at google.com> wrote:
>
>
> We could specify that WeakMaps can use typed objects as keys. The current
> discussion in your article confuses semantics with implementation when it
> speaks of typed objects comparing structurally. Typed objects have
> identity, characterized by the four-tuple you explain. Just as all the bits
> of a thin pointer are significant when comparing two thin pointers to see
> if they point at the same semantic object identity, so are all the bits in
> your fat pointer significant. Don't get confused by the bits in the pointer
> to the fat pointer, when the fat pointer happens to be boxed.
>
It is unclear to me how WeakMaps can ever use typed objects as keys, since
typed objects do not have their unique identity. Or rather, the only
possible semantics I see is "hold to the value forever". So for example:
w = new WeakMap();
w[Point(buffer, 0)] = "abc"; // 1
w[Point(buffer,0)] = ? // 2
I believe that in line 2, result should always be "abc" (since
Point(buffer, 0) === Point(buffer, 0)).
This is something we can spec, but it is probably not behavior we want.
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140402/411e7989/attachment.html>
More information about the es-discuss
mailing list