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 obje

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 le

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
> 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: 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 pa

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 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 — > just FYI > > > On Jun

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 del(

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 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 — > just

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 wrote: > > On 6/17/15 2:35 PM, Mark S. Miller wrote: >> What do other browsers currently do? >

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: Att

Re: Template site objects and WeakMap

2015-06-17 Thread Mark S. Miller
On Wed, Jun 17, 2015 at 11:19 AM, Yusuke SUZUKI 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 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 > > (*key*) is not Object, throw a *TypeError* exception. > >

Re: Template site objects and WeakMap

2015-06-17 Thread Mark S. Miller
On Wed, Jun 17, 2015 at 9:31 AM, Yusuke SUZUKI wrote: > On Thu, Jun 18, 2015 at 1: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! >> >> >>

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 wrote: > > Could I not use `Object(Symbol.for('some global registry symbol'))` as a > `WeakMap` key? That wo

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 http://www.ecma-international.

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 wrote: > > congratulations and THANK YOU! I learned something important reading > your messages. The

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 o

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 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 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 some context..

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-17 Thread Yusuke SUZUKI
On Wed, Jun 17, 2015 at 10:41 PM, Mark Miller 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 those same obj

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 o

Re: Template site objects and WeakMap

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

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 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 PM, Yusuke SU

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 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 costly, and using weak ref

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
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 collecti

Re: Template site objects and WeakMap

2015-06-16 Thread Caitlin Potter
It sounds like this is discussing the implementation in V8, unless it’s done similarly in other engines. Possibly it’s talking about a polyfill mechanism that might be used in compile-to-js implementations that target older browsers. V8’s template map is a Map with smi keys representing the hash

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 wrote: > Hi forks, > > In ES6 spec, template site objects are strongly referenced by the > realm.[[