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
Hi Yusuke, 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

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
On Wed, Jun 17, 2015 at 10:41 PM, Mark Miller erig...@gmail.com wrote: Hi Yusuke, 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

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
Thanks. And sorry for the late reply. On Wed, Jun 17, 2015 at 11:31 AM, Mark S. Miller erig...@google.com wrote: Hi Yusuke, I am not sure I understood your message. Could you show some example code that would observe the observable difference you have in mind? On Tue, Jun 16, 2015 at 7:25

Re: Template site objects and WeakMap

2015-06-16 Thread Yusuke SUZUKI
On Wed, Jun 17, 2015 at 2:29 PM, Yusuke SUZUKI utatane@gmail.com wrote: Thanks. And sorry for the late reply. On Wed, Jun 17, 2015 at 11:31 AM, Mark S. Miller erig...@google.com wrote: Hi Yusuke, I am not sure I understood your message. Could you show some example code that would

Re: Template site objects and WeakMap

2015-06-16 Thread Mark S. Miller
Hi Yusuke, I am not sure I understood your message. Could you show some example code that would observe the observable difference you have in mind? On Tue, Jun 16, 2015 at 7:25 PM, Yusuke SUZUKI utatane@gmail.com wrote: Hi forks, In ES6 spec, template site objects are strongly

Re: Template site objects and WeakMap

2015-06-16 Thread Mark S. Miller
If WeakSets were iterable, then any such optimization would be observable and therefore disallowed. It is precisely the unobservability of GC that give us the freedom to engage in such transparent optimizations. The platform can certainly provide itself with internal iterable WeakSet-like

Re: Template site objects and WeakMap

2015-06-16 Thread Caitlin Potter
It’s not related to observability, this just isn’t used currently, and probably wouldn’t be much of an improvement if it were. Creating the template callsites themselves is pretty costly, and using weak references to the callsites would, in the majority of cases, mean recreating them every time

Re: Template site objects and WeakMap

2015-06-16 Thread Mark S. Miller
Thanks. That is clarifying. On Tue, Jun 16, 2015 at 8:12 PM, Caitlin Potter caitpotte...@gmail.com wrote: It’s not related to observability, this just isn’t used currently, and probably wouldn’t be much of an improvement if it were. Creating the template callsites themselves is pretty