Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Alex Russell
On Nov 19, 2012, at 11:16 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: For several things in the DOM and related APIs, we want objects that are more-or-less the same as some basic ES stuff, like Arrays or Maps, and which are appropriate to treat as those objects in a generic manner. For

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Alex Russell
Actually, looking at this IDL more closely, I see unneeded invariants causing most of the problem. If URLQuery subclasses Map (assuming we make this possible, which we should), it only needs to promise to hand back strings, not take them. The behavior can simply be defined as toString()-ing the

Re: Problems with strict-mode caller poisoning

2012-11-20 Thread Andreas Rossberg
On 16 November 2012 22:19, Jeff Walden jwalden...@mit.edu wrote: On 11/16/2012 07:06 AM, Brendan Eich wrote: So it seems to me premature to throw on [[GetOwnProperty]] of a strict function's 'caller'. It would be more precise, and avoid the problem you're hitting, to return a property

RE: Subclassing basic types in DOM - best method?

2012-11-20 Thread Domenic Denicola
For URLQuery in particular, since it's a String-String map, why not just use a plain-old-JavaScript-object with appropriate interceptions via a proxy? This provides a much more idiomatic API: new URLQuery(object) stays the same urlQuery.get(name) - urlQuery[name][0] urlQuery.getAll(name) -

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Alex Russell
I think the basic issue here is that DOM is over-specifying the constraints (I assume because WebIDL makes that most natural?), not the available JS hacks to implement their weirdo type constraints. Lets not feed the misdesign trolls = ) On Tue, Nov 20, 2012 at 2:25 PM, Domenic Denicola

Re: Problems with strict-mode caller poisoning

2012-11-20 Thread Allen Wirfs-Brock
On Nov 20, 2012, at 4:01 AM, Andreas Rossberg wrote: On 16 November 2012 22:19, Jeff Walden jwalden...@mit.edu wrote: On 11/16/2012 07:06 AM, Brendan Eich wrote: So it seems to me premature to throw on [[GetOwnProperty]] of a strict function's 'caller'. It would be more precise, and avoid

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Erik Arvidsson
On Tue, Nov 20, 2012 at 9:25 AM, Domenic Denicola dome...@domenicdenicola.com wrote: For URLQuery in particular, since it's a String-String map, why not just use a plain-old-JavaScript-object with appropriate interceptions via a proxy? This provides a much more idiomatic API: new

Re: [Bug 20019] Support subclassing ES6 Map

2012-11-20 Thread Mark S. Miller
[+es-discuss] Speaking only for myself at this point -- I do not recall MultiMap previously being suggested to the committee. I think adding a MultiMap API to ES7 is a good idea. Neither Map nor MultiMap should be a subclass of the other, since neither is an LSP subtype of the other. Since Map

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Tab Atkins Jr.
On Mon, Nov 19, 2012 at 9:46 PM, Brendan Eich bren...@mozilla.com wrote: Tab Atkins Jr. wrote: If we did this, the only reason to continue subclassing Map is to get instanceof checks to work. Is this acceptable? I think it's either irrelevant (no one tests 'aUrlQuery instanceof Map') or

Re: [Bug 20019] Support subclassing ES6 Map

2012-11-20 Thread Kris Kowal
On Tue, Nov 20, 2012 at 10:57 AM, Mark S. Miller erig...@google.com wrote: Since Map and Set will be in ES6 and MultiMap is trivially implementable from these, we can wait until we see some experimental implementations before standardizing. Hence the ES7 target. Here’s my experimental

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Tab Atkins Jr.
On Tue, Nov 20, 2012 at 3:28 AM, Alex Russell a...@dojotoolkit.org wrote: Actually, looking at this IDL more closely, I see unneeded invariants causing most of the problem. If URLQuery subclasses Map (assuming we make this possible, which we should), Already possible. AWB posted code to

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Tab Atkins Jr.
On Tue, Nov 20, 2012 at 9:38 AM, Erik Arvidsson erik.arvids...@gmail.com wrote: On Tue, Nov 20, 2012 at 9:25 AM, Domenic Denicola dome...@domenicdenicola.com wrote: For URLQuery in particular, since it's a String-String map, why not just use a plain-old-JavaScript-object with appropriate

Re: [Bug 20019] Support subclassing ES6 Map

2012-11-20 Thread Tab Atkins Jr.
On Tue, Nov 20, 2012 at 10:57 AM, Mark S. Miller erig...@google.com wrote: [+es-discuss] Speaking only for myself at this point -- I do not recall MultiMap previously being suggested to the committee. I think adding a MultiMap API to ES7 is a good idea. Neither Map nor MultiMap should be a

Re: [Bug 20019] Support subclassing ES6 Map

2012-11-20 Thread Mark S. Miller
On Tue, Nov 20, 2012 at 12:30 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Tue, Nov 20, 2012 at 10:57 AM, Mark S. Miller erig...@google.com wrote: [+es-discuss] Speaking only for myself at this point -- I do not recall MultiMap previously being suggested to the committee. I think

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Rick Waldron
On Tue, Nov 20, 2012 at 2:45 PM, Tab Atkins Jr. jackalm...@gmail.comwrote: On Mon, Nov 19, 2012 at 9:46 PM, Brendan Eich bren...@mozilla.com wrote: Tab Atkins Jr. wrote: If we did this, the only reason to continue subclassing Map is to get instanceof checks to work. Is this acceptable?

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Tab Atkins Jr.
On Tue, Nov 20, 2012 at 1:31 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Nov 20, 2012 at 2:45 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Mon, Nov 19, 2012 at 9:46 PM, Brendan Eich bren...@mozilla.com wrote: Tab Atkins Jr. wrote: If we did this, the only reason to continue

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Peter van der Zee
On Tue, Nov 20, 2012 at 10:31 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Nov 20, 2012 at 2:45 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Mon, Nov 19, 2012 at 9:46 PM, Brendan Eich bren...@mozilla.com wrote: Tab Atkins Jr. wrote: If we did this, the only reason to

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Rick Waldron
On Tue, Nov 20, 2012 at 4:54 PM, Peter van der Zee e...@qfox.nl wrote: On Tue, Nov 20, 2012 at 10:31 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Nov 20, 2012 at 2:45 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Mon, Nov 19, 2012 at 9:46 PM, Brendan Eich

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Rick Waldron
On Tue, Nov 20, 2012 at 4:52 PM, Tab Atkins Jr. jackalm...@gmail.comwrote: On Tue, Nov 20, 2012 at 1:31 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Nov 20, 2012 at 2:45 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: On Mon, Nov 19, 2012 at 9:46 PM, Brendan Eich

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Rick Waldron
On Tue, Nov 20, 2012 at 3:08 PM, Tab Atkins Jr. jackalm...@gmail.comwrote: On Tue, Nov 20, 2012 at 3:28 AM, Alex Russell a...@dojotoolkit.org wrote: Actually, looking at this IDL more closely, I see unneeded invariants causing most of the problem. If URLQuery subclasses Map (assuming we

Fwd: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Allen Wirfs-Brock
Tom Van Custem have been having some email discussion while I work on integrating Proxys into the ES6 spec. He and I agree that some broader input would be useful so I'm going to forward some of the message here to es-discuss and carry the discussion forward here. Here is the first message

Re: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Tom Van Cutsem
Hi Allen, 2012/11/18 Allen Wirfs-Brock al...@wirfs-brock.com The proxy spec.for Object.getOwnPropertyNames/kets/etc. seem to be doing quite a bit more than this. They 1) always copy the array returned from the trap? Why is this necessary? Sure the author of a trap should probably always

Re: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Allen Wirfs-Brock
On Nov 19, 2012, at 10:04 AM, Tom Van Cutsem wrote: Hi Allen, 2012/11/18 Allen Wirfs-Brock al...@wirfs-brock.com The proxy spec.for Object.getOwnPropertyNames/kets/etc. seem to be doing quite a bit more than this. They 1) always copy the array returned from the trap? Why is this

Re: [Bug 20019] Support subclassing ES6 Map

2012-11-20 Thread Tab Atkins Jr.
On Tue, Nov 20, 2012 at 1:06 PM, Mark S. Miller erig...@google.com wrote: This is all very tricky and you may be able to make it work. But why? Do you anticipate passing a multimap into a place that expects a map? For these use cases, do you expect that the passer of the multimap reliably

Re: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Tom Van Cutsem
2012/11/19 Allen Wirfs-Brock al...@wirfs-brock.com On Nov 19, 2012, at 10:04 AM, Tom Van Cutsem wrote: The copying is to ensure: a) that the result is an Array Why is Array-ness essential? It was what ES5 specified, but ES5 had a fixed implementations of Object.getOwnPropertyNames/keys so

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Tab Atkins Jr.
On Tue, Nov 20, 2012 at 2:02 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Nov 20, 2012 at 4:52 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: Of course, that pattern is broken too - it lets you detect actual Arrays, but not things that subclass Array. That's not possible in

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Tab Atkins Jr.
On Tue, Nov 20, 2012 at 2:06 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Nov 20, 2012 at 3:08 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: Nope, that's not good enough. For example, you have to do input cleanup (replacing lone surrogates with U+FFFD, escaping , etc.) which

Fwd: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Allen Wirfs-Brock
(for some reason the followup message didn't seem to make it to es-discuss the first time I redirected them. so here goes using an alternative technique. Sorry in advance with we end up with duplicate messages) Begin forwarded message: From: Tom Van Cutsem tomvc...@gmail.com Date: November

Fwd: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Allen Wirfs-Brock
Begin forwarded message: From: Allen Wirfs-Brock al...@wirfs-brock.com Date: November 19, 2012 2:11:52 PM PST To: Tom Van Cutsem tomvc...@gmail.com Cc: Mark S. Miller erig...@google.com, Jason Orendorff jorendo...@mozilla.com Subject: Re: possible excessive proxy invariants for

Fwd: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Allen Wirfs-Brock
Begin forwarded message: From: Tom Van Cutsem tomvc...@gmail.com Date: November 20, 2012 11:36:24 AM PST To: Allen Wirfs-Brock al...@wirfs-brock.com Cc: Mark S. Miller erig...@google.com, Jason Orendorff jorendo...@mozilla.com Subject: Re: possible excessive proxy invariants for

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Rick Waldron
On Tuesday, November 20, 2012 at 5:23 PM, Tab Atkins Jr. wrote: On Tue, Nov 20, 2012 at 2:02 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Nov 20, 2012 at 4:52 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: Of course, that pattern is broken too - it lets you detect actual

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Rick Waldron
On Tuesday, November 20, 2012 at 5:25 PM, Tab Atkins Jr. wrote: On Tue, Nov 20, 2012 at 2:06 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tue, Nov 20, 2012 at 3:08 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: Nope, that's not good enough. For example, you have to do input

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Tab Atkins Jr.
On Tue, Nov 20, 2012 at 2:52 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tuesday, November 20, 2012 at 5:23 PM, Tab Atkins Jr. wrote: function foo() {...} foo.prototype = []; var a = new foo(); a.push(1); a.length; // 1 a.length = 0; console.log(a); {0:1,length:0} Again, it's

Re: Subclassing basic types in DOM - best method?

2012-11-20 Thread Tab Atkins Jr.
Could you use a client that quotes properly? Your responses keep flattening the quotes to a single level, making it impossible to tell where each ends. On Tue, Nov 20, 2012 at 2:56 PM, Rick Waldron waldron.r...@gmail.com wrote: On Tuesday, November 20, 2012 at 5:25 PM, Tab Atkins Jr. wrote:

Re: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Brandon Benvie
In regards to the non-configurable/extensible issue, the issue is that the proxy still needs to be *notified* of what's happening, but it's not really allowed to *trap* because the result is predetermined. Currently this is handled by treating it like a normal trap activation with extra

Re: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Allen Wirfs-Brock
and my first reply, direct to es-discuss... On Nov 20, 2012, at 2:32 PM, Allen Wirfs-Brock wrote: Begin forwarded message: From: Tom Van Cutsem tomvc...@gmail.com Date: November 20, 2012 11:36:24 AM PST To: Allen Wirfs-Brock al...@wirfs-brock.com Cc: Mark S. Miller erig...@google.com,

Re: possible excessive proxy invariants for Object.keys/etc??

2012-11-20 Thread Allen Wirfs-Brock
On Nov 20, 2012, at 3:16 PM, Brandon Benvie wrote: In regards to the non-configurable/extensible issue, the issue is that the proxy still needs to be *notified* of what's happening, but it's not really allowed to *trap* because the result is predetermined. Currently this is handled by