Re: direct_proxies problem

2013-01-10 Thread David Bruant
Le 09/01/2013 23:57, Andrea Giammarchi a écrit : do you have any example of what you are saying? all my examples fail and I don't understand other use cases. I don't. You seem to be relying a lot on the Firefox implementation, but there are 2 things to be aware of as far as I know (sorry I

RE: Object iteration order

2013-01-10 Thread François REMY
Just to return back on the initial question: The event stuff is a distraction and was merely to illustrate. See https://www.w3.org/Bugs/Public/show_bug.cgi?id=20158#c1 For the APIs we define in DOM-land we aim to have them fully deterministic even when developers do strange things. Why not

Re: Object iteration order

2013-01-10 Thread Anne van Kesteren
On Thu, Jan 10, 2013 at 12:47 PM, François REMY francois.remy@outlook.com wrote: Why not order the keys alphabetically when you use them in a DOM API? We could, however if iteration order is eventually defined it would be kind of annoying if we sorted things. -- http://annevankesteren.nl/

RE: Object iteration order

2013-01-10 Thread François REMY
We could, however if iteration order is eventually defined it would be kind of annoying if we sorted things. Even if iteration order is going to be defined in some way, I doubt it will be intuitive in any way. But I could be wrong, this is just a personal belief.

Re: Object iteration order

2013-01-10 Thread Anne van Kesteren
On Thu, Jan 10, 2013 at 1:22 PM, François REMY francois.remy@outlook.com wrote: Even if iteration order is going to be defined in some way, I doubt it will be intuitive in any way. But I could be wrong, this is just a personal belief. Based on what? The iteration order of keys that are

WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Nathan Wall
Choosing symbols or a weakmap would make a huge difference in how proxy  replacement would react to DOM algorithms. If the DOM in terms of accessing private properties, then proxies can  replace DOM objects transparently. Their unknownPrivateSymbol trap  will be called [2] and if they don't

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Herby Vojčík
Nathan Wall wrote: // ES6 Symbols // Forgive me for not knowing what the current // correct syntax is for creating a symbol: let timestamp = new Symbol(); class SimpleDate { construct(time) { this.setTime(time); }

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread David Bruant
Le 10/01/2013 17:22, Nathan Wall a écrit : Choosing symbols or a weakmap would make a huge difference in how proxy replacement would react to DOM algorithms. If the DOM in terms of accessing private properties, then proxies can replace DOM objects transparently. Their unknownPrivateSymbol trap

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Brendan Eich
Nathan Wall wrote: In the case of (1), the implementation using a private symbol will have internal accesses to the `timestamp` symbol exposed through the unknownPrivateSymbol trap. Private symbols do not trap. In the case of (2), the implementation using a private symbol will fail on a

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread David Bruant
Le 10/01/2013 17:41, Brendan Eich a écrit : Nathan Wall wrote: In the case of (1), the implementation using a private symbol will have internal accesses to the `timestamp` symbol exposed through the unknownPrivateSymbol trap. Private symbols do not trap. They do trap, but they don't leak.

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Brandon Benvie
At the very least, WeakMaps are potentially usable today (depending on the target audience) while symbols are nowhere in sight. I’ve gotten a lot of mileage out of this function, which as you said provides a similar effective result as symbols (they differ in that the WeakMap version isn’t

RE: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Domenic Denicola
It's funny: I've been considering a similar thread, but the opposite. I.e. private symbols better than weak maps? In particular, given the freezing clarification, the use cases for weak maps instead of private symbols seem to reduce to adding *new* symbols to extension-prevented objects. Is

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Brandon Benvie
They both have their place since there's many uses for both inherited and non-inherited private values. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Brendan Eich
Allen rightly has pointed out several times on es-discuss that WeakMaps require GC special handling and are costly, compared to private symbols. This is true not only for GC time, but especially for get/set runtime. Properties named by Symbols, when implemented, should have the same

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Kevin Smith
They both have their place since there's many uses for both inherited and non-inherited private values. Can we see some demonstrated use-cases for which WeakMaps are insufficient, and private properties are? I continue to hear that private symbols are a great idea without any discussion of

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Erik Arvidsson
Private symbols should be faster. No need for hashing and GC of an object with private symbols is the exact same GC as any other object. Getting the GC behavior of a WeakMap is a lot harder (and thus slower). ...also what Brendan just said. On Thu, Jan 10, 2013 at 11:50 AM, Brandon Benvie

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Erik Arvidsson
On Thu, Jan 10, 2013 at 11:55 AM, Kevin Smith khs4...@gmail.com wrote: They both have their place since there's many uses for both inherited and non-inherited private values. Can we see some demonstrated use-cases for which WeakMaps are insufficient, and private properties are? I continue

RE: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Domenic Denicola
From: Brandon Benvie [bran...@brandonbenvie.com] Sent: Thursday, January 10, 2013 11:50 They both have their place since there's many uses for both inherited and non-inherited private values. Of course, (non-)inheritance is a great point. Amusingly, using conventional OO terminology, it

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Brendan Eich
Symbols (private or public, don't forget the latter) are crucial to ES6 and not going away :-|. Besides the property access and GC costs of WeakMaps (which are probably fine, but at least inevitable, when you really do need a WeakMap), symbols allow coordination between friendly objects by

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Brendan Eich
Domenic Denicola wrote: From: Brandon Benvie [bran...@brandonbenvie.com] Sent: Thursday, January 10, 2013 11:50 They both have their place since there's many uses for both inherited and non-inherited private values. Of course, (non-)inheritance is a great point. Amusingly, using

RE: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Nathan Wall
Brendan Eich wrote: Nathan Wall wrote: In the case of (2), the implementation using a private symbol will fail on a call to `setTime` when the object is frozen (I think). Nope, we agreed that frozen objects support setting pre-existing (added before the object was made non-extensible)

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Brendan Eich
Nathan Wall wrote: Brendan Eich wrote: Nathan Wall wrote: In the case of (2), the implementation using a private symbol will fail on a call to `setTime` when the object is frozen (I think). Nope, we agreed that frozen objects support setting pre-existing (added before the object was made

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Kris Kowal
As an aside, Irakli Gozashvili and I independently realized that you could use a WeakMap for parallel objects with inheritance. Very similar to Brendan’s createStorage, we put together a parallel universe constructor. function Parallel(root) { var parallel = new WeakMap(); root = root ||

RE: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Nathan Wall
Brendan Eich: No, not if the symbol is not in the whitelist. Zero information leak is required. That's good news too. Objection withdrawn. I guess I didn't correctly understand David's point in the direct_proxies thread then :-/. I'll have to reread it more carefully. Thanks for the

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Allen Wirfs-Brock
On Jan 10, 2013, at 8:41 AM, Brendan Eich wrote: Nathan Wall wrote: In the case of (1), the implementation using a private symbol will have internal accesses to the `timestamp` symbol exposed through the unknownPrivateSymbol trap. Private symbols do not trap. In the case of (2), the

RE: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Nathan Wall
Brendan Eich: No, not if the symbol is not in the whitelist. Zero information leak is required. That's good news too. Objection withdrawn. Maybe I gave up too easy :). Is the `unknownPrivateSymbol` trap called? What's the rationale for this trap?

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Kevin Smith
Symbols (private or public, don't forget the latter) are crucial to ES6 and not going away :-|. No problem here with public symbols! They provide collision-free property naming without changing the underlying object model. Woot! But when I ask for use cases for private symbols, I get

RE: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Domenic Denicola
Really?? http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.15.5 From: es-discuss-boun...@mozilla.org [es-discuss-boun...@mozilla.org] on behalf of Rick Waldron [waldron.r...@gmail.com] Sent: Thursday, January 10, 2013 14:57 To: Nathan Wall Cc:

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Allen Wirfs-Brock
Right, that's not how the spec. is written. You certainly could do that on a per instance basis by copying down the methods. Perhaps even define yourself a subclass to do so. But it would be silly to force this on every instance. On Jan 10, 2013, at 12:04 PM, Domenic Denicola wrote:

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Rick Waldron
On Thu, Jan 10, 2013 at 3:04 PM, Domenic Denicola dome...@domenicdenicola.com wrote: Really?? http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.15.5 Wow, yep. For some reason, when I saw that example, I only recalled the original WeakMap proposal—which is 2 years out of date. VERY

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Rick Waldron
On Thu, Jan 10, 2013 at 3:14 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: Right, that's not how the spec. is written. You certainly could do that on a per instance basis by copying down the methods. Perhaps even define yourself a subclass to do so. But it would be silly to force this

Re: WeakMap better than Private Symbols? (was: direct_proxies problem)

2013-01-10 Thread Brendan Eich
Nathan Wall wrote: Brendan Eich: No, not if the symbol is not in the whitelist. Zero information leak is required. That's good news too. Objection withdrawn. Maybe I gave up too easy :). Is the `unknownPrivateSymbol` trap called? What's the rationale for this trap?

unknownPrivateSymbol trap (was: WeakMap better than Private Symbols? (was: direct_proxies problem))

2013-01-10 Thread David Bruant
[Cc'ing Tom and Mark to be sure there is agreement on what I'm claiming in this message] Le 10/01/2013 22:10, Brendan Eich a écrit : Nathan Wall wrote: Brendan Eich: No, not if the symbol is not in the whitelist. Zero information leak is required. That's good news too. Objection withdrawn.

Re: unknownPrivateSymbol trap (was: WeakMap better than Private Symbols? (was: direct_proxies problem))

2013-01-10 Thread Tab Atkins Jr.
On Thu, Jan 10, 2013 at 1:24 PM, David Bruant bruan...@gmail.com wrote: I think the return true/false protocol should be replaced by a return/throw protocol (return value is ignored). It'd be much more explicit this way. FWIW, I kinda like the aesthetics of return/throw a bit better too,

Re: unknownPrivateSymbol trap (was: WeakMap better than Private Symbols? (was: direct_proxies problem))

2013-01-10 Thread Brendan Eich
David Bruant wrote: [Cc'ing Tom and Mark to be sure there is agreement on what I'm claiming in this message] Le 10/01/2013 22:10, Brendan Eich a écrit : Nathan Wall wrote: Brendan Eich: No, not if the symbol is not in the whitelist. Zero information leak is required. That's good news too.

Re: unknownPrivateSymbol trap (was: WeakMap better than Private Symbols? (was: direct_proxies problem))

2013-01-10 Thread David Bruant
Le 10/01/2013 22:31, Tab Atkins Jr. a écrit : On Thu, Jan 10, 2013 at 1:24 PM, David Bruant bruan...@gmail.com wrote: I think the return true/false protocol should be replaced by a return/throw protocol (return value is ignored). It'd be much more explicit this way. FWIW, I kinda like the

RE: direct_proxies problem

2013-01-10 Thread Nathan Wall
David Bruant wrote: For the long term, I expected DOM objects could be proxified.  Boris convinced me otherwise for DOM Nodes at least.  Are you so convinced that the `unknownPrivateSymbol` trap is necessary? It's been decided early that a Proxy.isProxy method should be avoided,  because

RE: direct_proxies problem

2013-01-10 Thread Nathan Wall
   function isNodeProxy(node) {        try {            return node instanceof Node                document.body.appendChild(node)                !!document.body.removeChild(node);        } catch(x) {            return false;        }    } Excuse me, I got the logic wrong:    

Re: direct_proxies problem

2013-01-10 Thread Brendan Eich
Jason Orendorff wrote: On Tue, Jan 8, 2013 at 11:54 PM, Brendan Eich bren...@mozilla.com mailto:bren...@mozilla.com wrote: Boris and I talked more 1:1 -- it is not clear when a direct proxy can be safely cast to its target. The internal proxies Gecko uses are known implementations