Template site objects and WeakMap

Andrea Giammarchi andrea.giammarchi at gmail.com
Wed Jun 17 19:39:15 UTC 2015

actually I was surprised the apparently mentioned native behavior looked
too much like my Symbol based WeakMap partial poly:


var WeakMap = WeakMap || (function (s) {'use strict';
  function WeakMap() {
    this[s] = Symbol('WeakMap');
  WeakMap.prototype = {
    'delete': function del(o) {
      delete o[this[s]];
    get: function get(o) {
      return o[this[s]];
    has: function has(o) {
      return -1 < Object.getOwnPropertySymbols(o).indexOf(this[s]);
    set: function set(o, v) {
      o[this[s]] = v;
  return WeakMap;


weird to say the least, and yet I've no idea why that realm check would be
needed/done/reliable per each WeakMap.

Sorry for the noise, if any

On Wed, Jun 17, 2015 at 6:54 PM, Jordan Harband <ljharb at gmail.com> wrote:

> Could I not use `Object(Symbol.for('some global registry symbol'))` as a
> `WeakMap` key? That would return a realm-specific object, of course.
> On Wed, Jun 17, 2015 at 10:19 AM, Benjamin Gruenbaum <inglor at gmail.com>
> wrote:
>> > congratulations and THANK YOU! I learned something important reading
>> your messages. The notion that we can preserve non-observability when
>> making one thing a WeakMap iff we make all other WeakMaps be strong for
>> those same objects is true, novel, and very surprising. I have been working
>> on such concepts for decades and never come across anything like it.
>> I apologize, I understand the problem with a weak registry forcing
>> observable garbage collection in user code - that's nice but isn't this
>> always the case with references to objects when an object pool/flyweight is
>> used?
>> Isn't this the same issue as `==` working on strings that have string
>> objects interned but possibly GC'd (and precisely why Java never collects
>> interned strings)?
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150617/271075a9/attachment.html>

More information about the es-discuss mailing list