Re: Template site objects and WeakMap

2015-06-17 Thread Mark S. Miller
On Wed, Jun 17, 2015 at 11:19 AM, Yusuke SUZUKI utatane@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

Re: Template site objects and WeakMap

2015-06-17 Thread Boris Zbarsky
On 6/17/15 2:35 PM, Mark S. Miller wrote: What do other browsers currently do? Firefox: var w = new WeakMap(); var r = Symbol.for('foo'); w.set(r, true); TypeError: r is not a non-null object WebKit nightly: var w = new WeakMap(); var r = Symbol.for('foo'); w.set(r, true); TypeError:

Re: Re: Template site objects and WeakMap

2015-06-17 Thread Andrea Giammarchi
actually I was surprised the apparently mentioned native behavior looked too much like my Symbol based WeakMap partial poly: ```js var WeakMap = WeakMap || (function (s) {'use strict'; function WeakMap() { this[s] = Symbol('WeakMap'); } WeakMap.prototype = { 'delete': function

Re: Template site objects and WeakMap

2015-06-17 Thread Yusuke SUZUKI
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

Re: Template site objects and WeakMap

2015-06-17 Thread Mark S. Miller
TypeError: Invalid value used as weak map key Yes, already fixed on v8. Thanks. On Wed, Jun 17, 2015 at 11:51 AM, Caitlin Potter caitpotte...@gmail.com wrote: The v8 bug referred to earlier in this thread was filed by Rick Waldron and fixed back in March, I think engines are on the same

Re: Template site objects and WeakMap

2015-06-17 Thread Benjamin Gruenbaum
It would return a different object each time (for the same Symbol, like new String) so it would not exhibit the problem of being observable. On Jun 17, 2015, at 20:54, Jordan Harband ljh...@gmail.com wrote: Could I not use `Object(Symbol.for('some global registry symbol'))` as a `WeakMap`

Re: Template site objects and WeakMap

2015-06-17 Thread Mark S. Miller
On Wed, Jun 17, 2015 at 9:31 AM, Yusuke SUZUKI utatane@gmail.com wrote: On Thu, Jun 18, 2015 at 1:18 AM, Mark S. Miller erig...@google.com wrote: [+Allen] Can registered Symbols be used as keys in WeakMaps? If so, we have a fatal unauthorized communications channel that we need to fix

Re: Template site objects and WeakMap

2015-06-17 Thread Caitlin Potter
The v8 bug referred to earlier in this thread was filed by Rick Waldron and fixed back in March, I think engines are on the same page with this — just FYI On Jun 17, 2015, at 2:49 PM, Boris Zbarsky bzbar...@mit.edu wrote: On 6/17/15 2:35 PM, Mark S. Miller wrote: What do other browsers

Re: Template site objects and WeakMap

2015-06-17 Thread Andrea Giammarchi
uh ... never mind then, I don't even need to understand :D Cheers On Wed, Jun 17, 2015 at 7:51 PM, Caitlin Potter caitpotte...@gmail.com wrote: The v8 bug referred to earlier in this thread was filed by Rick Waldron and fixed back in March, I think engines are on the same page with this —

Re: Re: Template site objects and WeakMap

2015-06-17 Thread Jordan Harband
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 ing...@gmail.com wrote: congratulations and THANK YOU! I learned something important reading your

Re: Re: Template site objects and WeakMap

2015-06-17 Thread Benjamin Gruenbaum
Interning of a particular immutable-objects-with-identity in an interning table can still safely be weakly interned, by marking that object, at interning time, so all WeakMaps from then on hold it strongly Oh cool, I didn't realize that. That is pretty neat :) On Wed, Jun 17, 2015 at 10:54 PM,

Re: Template site objects and WeakMap

2015-06-17 Thread Boris Zbarsky
On 6/17/15 1:54 PM, Jordan Harband 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. Object(Symbol.for(x)) == Object(Symbol.for(x)) tests false. That's because

Re: Re: Template site objects and WeakMap

2015-06-17 Thread Mark S. Miller
The idea that (a shared Weak interning table of immutable-objects-with-identity + WeakMaps makes gc observable) is not new. The idea that (the shared interning tables of immutable-objects-with-identity must therefore be strong) is not new. What was new to me is the idea that Interning of a

Re: Template site objects and WeakMap

2015-06-17 Thread Andrea Giammarchi
this is puzzling me too ... so I've got few cases 1. you want/need a one to many relations, Symbol as key, Array as value, and you play with that Array values as needed per each Symbol used as key in the very same WeakMap 2. you invert the logic and you have a WeakMap that checks per each

Re: Template site objects and WeakMap

2015-06-17 Thread Allen Wirfs-Brock
On Jun 17, 2015, at 9:18 AM, Mark S. Miller wrote: [+Allen] Can registered Symbols be used as keys in WeakMaps? If so, we have a fatal unauthorized communications channel that we need to fix in the spec asap! No, symbols are not objects and the keys of WeakMaps must be objects. BTW,

Re: Re: Template site objects and WeakMap

2015-06-17 Thread Benjamin Gruenbaum
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

Re: Template site objects and WeakMap

2015-06-17 Thread Mark S. Miller
I am curious about what these are? But regardless, I would expect there to be examples where it would be useful if it weren't fatal. Regarding the issues in this thread, it actually would be safe to allow unregistered Symbols as keys. But unless these examples are tremendously compelling, please

Re: Template site objects and WeakMap

2015-06-17 Thread Mark Miller
by the WeakMap, siteObject will be collected. var siteObject = tag`hello`; map.get(siteObject); // false, but should be true. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects strongly (if we choose the weak reference

Re: Template site objects and WeakMap

2015-06-17 Thread Benjamin Gruenbaum
Aren't WeakMap keys only objects? On Jun 17, 2015, at 19:18, Mark S. Miller erig...@google.com wrote: [+Allen] Can registered Symbols be used as keys in WeakMaps? If so, we have a fatal unauthorized communications channel that we need to fix in the spec asap!

Re: Template site objects and WeakMap

2015-06-17 Thread Yusuke SUZUKI
On Thu, Jun 18, 2015 at 1:18 AM, Mark S. Miller erig...@google.com wrote: [+Allen] Can registered Symbols be used as keys in WeakMaps? If so, we have a fatal unauthorized communications channel that we need to fix in the spec asap! Why do registered Symbols appear? (oops, maybe I missed

Re: Template site objects and WeakMap

2015-06-17 Thread Yusuke SUZUKI
= tag`hello`; map.get(siteObject); // false, but should be true. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects strongly (if we choose the weak reference implementation for realm.[[templateMap]]). But this may

Re: Template site objects and WeakMap

2015-06-17 Thread Mark S. Miller
[+Allen] Can registered Symbols be used as keys in WeakMaps? If so, we have a fatal unauthorized communications channel that we need to fix in the spec asap! ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Template site objects and WeakMap

2015-06-16 Thread Yusuke SUZUKI
`hello`; map.get(siteObject); // false, but should be true. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects strongly (if we choose the weak reference implementation for realm.[[templateMap]]). But this may complicate

Re: Template site objects and WeakMap

2015-06-16 Thread Yusuke SUZUKI
(); // If realm.[[templateMap]] is implemente by the WeakMap, siteObject will be collected. var siteObject = tag`hello`; map.get(siteObject); // false, but should be true. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects

Template site objects and WeakMap

2015-06-16 Thread Yusuke SUZUKI
the property with it indirectly by using WeakMap. As a result, if the site objects are referenced by the realm weakly, users can observe it by using WeakMap. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects strongly (if we choose

Re: Template site objects and WeakMap

2015-06-16 Thread Mark S. Miller
, if the site objects are referenced by the realm weakly, users can observe it by using WeakMap. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects strongly (if we choose the weak reference implementation for realm.[[templateMap

Re: Template site objects and WeakMap

2015-06-16 Thread Mark S. Miller
are referenced by the realm weakly, users can observe it by using WeakMap. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects strongly (if we choose the weak reference implementation for realm.[[templateMap]]). But this may

Re: Template site objects and WeakMap

2015-06-16 Thread Caitlin Potter
with it indirectly by using WeakMap. As a result, if the site objects are referenced by the realm weakly, users can observe it by using WeakMap. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects strongly (if we choose the weak

Re: Template site objects and WeakMap

2015-06-16 Thread Mark S. Miller
WeakMap. As a result, if the site objects are referenced by the realm weakly, users can observe it by using WeakMap. To avoid this situation, we need to specially handle template site objects in WeakMap; WeakMap refers template site objects strongly (if we choose the weak reference