Re: Subclassing basic types in DOM - best method?

2012-11-21 Thread Brendan Eich
Tab Atkins Jr. wrote: let o = { items: function() {} }; would pass that test. I'm not sure how else you're supposed to detect iterables. It's not 'items', btw. The iterator-getter/maker is named 'iterator' in SpiderMonkey currently, and last I heard would be @iterator (well-known public

Re: Subclassing basic types in DOM - best method?

2012-11-21 Thread Alex Russell
On Nov 20, 2012, at 8:08 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: 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

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

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

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: