Proposal: Abstract References

Mark S. Miller erights at
Tue Oct 21 13:31:07 PDT 2014

On Tue, Oct 21, 2014 at 1:12 PM, Domenic Denicola <
domenic at> wrote:

> This is really cool, Kevin. Thanks for writing it up in more detail. I
> hope it gets a lot of attention.

First, I agree this is cool. I am very positive on this direction. Kudos!

> My initial worries are largely around the ergonomics---both for authors
> and implementers---if this is our solution for private state. In
> particular,  I don't think having to create a new WeakMap for every private
> "member" is very author-friendly. And in general, implementers have voiced
> (weak) objections to using weak maps for private state

We've realized a long time ago that WeakMaps should be implemented using
the so-called "transposed" representation. All the realistic use cases
either strongly prefer the transposed representation, or are neutral
between the two representations. With the transposed representation, the
storage logic is essentially the same as in the once-imagined private
symbol proposals.

> in saying that they're not designed to work efficiently in that manner.

Actually, they are. The problem is that initial implementations date from
before we appreciated the need for the transposed representation. The best
thing TC39 can do for the future of WeakMaps is to proceed assuming the
transposed representation.

> (And that was with the pattern of one WeakMap per class, not multiple!)

Actually, that leads to better efficiency, as each WeakMap identity plays
the role that private symbols would have played -- naming an individual
private field. Using only one WeakMap identity per class would require some
other means of naming the individual fields within that class' private
state, necessitating a costly additional level of indirection.

The relationship proposal this is based on indeed uses one WeakMap per
private field.

> That said, this is really elegant and if nothing else it seems like good
> underpinnings for some slightly-higher-level private state abstraction. And
> of course you know I <3 the "bind operator".
> Hope to hear other TC39ers' thoughts!
> -Domenic
> _______________________________________________
> es-discuss mailing list
> es-discuss at

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

More information about the es-discuss mailing list