Re: Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-05 Thread Romuald Quantin
Someone made an experiment with the Mozilla “getWeakReference” apparently. https://gist.github.com/Benvie/7123690 https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.getWeakReference I had this as granted with other languages, I still don’t understand

Re: Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-05 Thread Romuald Quantin
> 2. For security purposes, only code that has been explicitly given access to _both_ the weak map and a key may gain access to the value stored within the > weakmap. This is why there is no enumeration—if there were, then any code that could access the weak map could then also access all of the

Re: Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-05 Thread Brendan Eich
On Thu, Nov 5, 2015 at 12:30 AM Romuald Quantin wrote: > What is the problem in accessing the keys with any code, which is the same > behaviour for any other object in javascript: String, Array, Object and so > on. The point is being able to do on a weak key so code can be

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-05 Thread Tom Van Cutsem
2015-11-04 23:04 GMT+01:00 Matthew Robb : > > On Wed, Nov 4, 2015 at 4:46 PM, Tom Van Cutsem wrote: > >> 1) If a module A hands out a reference to, say, a function f to modules B >> and C, then C could use this primitive to replace f with its own

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-05 Thread Matthew Robb
On Thu, Nov 5, 2015 at 12:49 PM, Tom Van Cutsem wrote: > O.o is a much safer alternative to Proxy.startTrapping and covers at least > part of its use cases. ​Hmm. Okay so pretend all object's are really just proxies to whatever their internal backing might be. In this

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-05 Thread Benoit Marchant
Proxy at the granularity of a property would be perfect for that > On Nov 5, 2015, at 10:11, Matthew Robb wrote: > > >> On Thu, Nov 5, 2015 at 12:49 PM, Tom Van Cutsem wrote: >> O.o is a much safer alternative to Proxy.startTrapping and covers at

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-05 Thread Brendan Eich
I did watchpoints in SpiderMonkey in 1997 IIRC, implemented as replacement accessors under the hood. ES5 and unfrozen ordinary objects allow self-hosting of watchpoints (ES6 weakmaps and symbols help but are not required). We can't standardize watchpoints for all objects, of course. /be On Thu,

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-05 Thread Brendan Eich
You wrote 1. "pretend all object's are really just proxies to whatever their internal backing might be." 2. "without a baked in ability to intercede." 3. "What this does is give you something VERY close to a built in observable Model type on top of plain objects." These are not consistent

Re: Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-04 Thread Coroutines
On Wed, Nov 4, 2015 at 2:36 PM, Rick Waldron wrote: > On Wed, Nov 4, 2015 at 8:16 AM Coroutines wrote: >> obj[Symbol.weakValues] = true; >> obj[Symbol.weakProperties] = true; > 2. For security purposes, only code that has been explicitly given

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-04 Thread Tom Van Cutsem
2015-11-03 15:41 GMT+01:00 Matthew Robb : > I probably have a terrible understanding of how this all works at a low > level but I feel like a potential solution would be a method of "upgrading" > a non-proxy object to be a proxy. The reason accessors are being used as >

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-04 Thread Tom Van Cutsem
2015-11-04 0:22 GMT+01:00 Coroutines : > > With Object.observe() you get a global view of events generated by the > target object, with Proxy you need to replace references to the target > object with references to the Proxy. > > Now I'm changing my opinion again. We need

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-04 Thread Matthew Robb
On Wed, Nov 4, 2015 at 4:46 PM, Tom Van Cutsem wrote: > 1) If a module A hands out a reference to, say, a function f to modules B > and C, then C could use this primitive to replace f with its own proxied > version. Module B expects f to work as A intended, but module C can >

Re: Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-04 Thread Coroutines
On Wed, Nov 4, 2015 at 4:56 AM, Romuald Quantin wrote: > As an aside and as Coroutines, > > I never understood why there is this inability to enumerate WeakMap keys. > If I had it my way there would be no WeakMap or WeakSet. I'd have a Symbol.mode similar to Lua's __mode

Re: Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-04 Thread Romuald Quantin
As an aside and as Coroutines, I never understood why there is this inability to enumerate WeakMap keys. Back in the time of flash/as3, I made some modules to observe objects that were garbage collected, and this was extremely useful. This was only possible because the keys were utterable. I

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Tom Van Cutsem
2015-11-02 23:34 GMT+01:00 Coroutines : > > I come from Lua. In Lua we make proxy objects with metamethods. You > create an empty table/object and define a metatable with a __index and > __newindex to catch accesses and changes when a key/property doesn't > exist. I would

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Isiah Meadows
Lol... I feel I'm in an insane minority that can work relatively productively in Java 7 and Haskell both. Of course, I have a preference, but that preference lies around that of OCaml and Clojure. It's more the expression-based, impure functional languages that I'm most productive in. Observing

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread William Edney
For those interested in using Proxies in the future, here are the appropriate links to the two remaining holdouts (FF and MS Edge are already there): Safari/Webkit/JSC: https://bugs.webkit.org/show_bug.cgi?id=35731 Chrome/V8: https://code.google.com/p/v8/issues/detail?id=1543 Bug the

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Isiah Meadows
I'm neutral. On Tue, Nov 3, 2015, 15:43 Matthew Robb wrote: > Isiah, could you elaborate some? I can't quite tell if you are expressing > support for my suggestion or not. Thanks! > On Nov 3, 2015 12:13 PM, "Isiah Meadows" wrote: > >> Lol... I

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Benoit Marchant
So would I, it would open up some very efficient opportunities > On Nov 3, 2015, at 8:26 AM, Andrea Giammarchi > wrote: > > That would make functional-programming-oriented developers wining forever > about such monstrosity in specs ... I'd personally love such

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Matthew Robb
Isiah, could you elaborate some? I can't quite tell if you are expressing support for my suggestion or not. Thanks! On Nov 3, 2015 12:13 PM, "Isiah Meadows" wrote: > Lol... I feel I'm in an insane minority that can work relatively > productively in Java 7 and Haskell

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 12:20 AM, Tom Van Cutsem wrote: > What O.o would provide beyond Proxy is the ability to observe changes to > already pre-existing objects. I think I missed something important here. You can watch for events with both Proxy and Object.observe() - but

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 3:22 PM, Coroutines wrote: > But because of what Object.observe() can do to see into closures, I'd > relegate it to privileged code :> It is incredibly useful for > debugging. I really need to make sure my thoughts are complete before I send a

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 7:33 PM, Isiah Meadows wrote: > There's a reason Object.observe is async: it prevents you from changing how > the value is first assigned, so it can't work like a proxy. And question: > how does it let you see hidden closures? In JS it is common to

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Isiah Meadows
I was just thinking... Object.observe could, in theory, be used as a core for a dispatcher and store in a Flux-like data flow. Basically, when a view emits an event, you can use the first observed object as a memoized dispatcher, and then it emits a list of changes that can then update another

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Isiah Meadows
There's a reason Object.observe is async: it prevents you from changing how the value is first assigned, so it can't work like a proxy. And question: how does it let you see hidden closures? On Tue, Nov 3, 2015, 18:28 Coroutines wrote: > On Tue, Nov 3, 2015 at 3:22 PM,

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Isiah Meadows
You can't get anything related to actual object access from Object.observe. If you observe String, you can only get the following events: - "add": String.newProp = value - "update": String.existingProp = newValue - "delete": delete String.prop - "reconfigure": Object.defineProperty(String, ...) -

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Brendan Eich
Ah yes, the Smalltalk "become:" message, something that inspired SpiderMonkey's "Brain Transplants" -- see the [1] footnote at https://brendaneich.com/2010/11/proxy-inception/, and of course the bugzilla link, which leads to this: Brendan

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Matthew Robb
I probably have a terrible understanding of how this all works at a low level but I feel like a potential solution would be a method of "upgrading" a non-proxy object to be a proxy. The reason accessors are being used as they are now is because you can retro fit them. Maybe what I am suggesting is

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Andrea Giammarchi
That would make functional-programming-oriented developers wining forever about such monstrosity in specs ... I'd personally love such possibility! Regards On Tue, Nov 3, 2015 at 2:41 PM, Matthew Robb wrote: > I probably have a terrible understanding of how this all

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-02 Thread Andrea Giammarchi
Not sure I've got your idea right but I think the main point of WeakAnything is to forget about GC and have them **not** observable "at all costs" unless I've misunderstood the intent itself, Object.observe as it has been proposed wouldn't help much anyway. Regards On Mon, Nov 2, 2015 at

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-02 Thread Mark S. Miller
On Mon, Nov 2, 2015 at 6:02 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > Not sure I've got your idea right but I think the main point of > WeakAnything is to forget about GC and have them **not** observable "at all > costs" > That is true of WeakMap and WeakSet. But there is a