W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

Re: What type should .findAll return

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Fri, 11 Nov 2011 16:16:42 -0800
Cc: Boris Zbarsky <bzbarsky@mit.edu>, public-script-coord@w3.org, public-webapps <public-webapps@w3.org>
Message-Id: <07D5E3B5-A009-4263-8209-69B754351DC5@wirfs-brock.com>
To: Jonas Sicking <jonas@sicking.cc>

On Nov 11, 2011, at 3:57 PM, Jonas Sicking wrote:

> On Fri, Nov 11, 2011 at 3:07 PM, Allen Wirfs-Brock
> <allen@wirfs-brock.com> wrote:
>>> ...
>> This is a problem for ES<=5.  Filter and all the other similar Array.prototype functions are specified to produce an object created as if by calling: new Array();
>> I have a scheme that we can probably get in place for ES.next that would allow filter and friends to produce NodeArray's for you, but I don't see how that helps right now.
> Well, if we can get implementations to implement this new scheme for
> the existing filter-like functions at the same time as they implement
> .findAll, then we should be golden.

the scheme depends upon other Es.next features including private names. It isn't clear that if you start pulling that thread how far it extends. But perhaps, it might fly...

> ...
>>> This would make myNodeArray.filter "work", but
>>> not Array.filter.
>> An inherent problem with this approach. But if your NodeArrays supplies correctly working over-rides there is probably little reason somebody would try to use the Array.prototype versions  with NodeArrays.
> Note that I was saying Array.filter and not Array.prototype.filter. My
> assumption was that if people call Array.prototype with an Array as
> the first argument, they would also do so with a NodeArray as first
> argument.

Array.filter and friends (in contrast to Array.prototype.filter) are not in ES5 and, so far, have not made the ES.next cut.  Personally, I'm not a bit fan of them for exactly this reason.  If you are building object-oriented "class" hierarchies you want to use methods, not global function that can't easily be virtually dispatched.  

Received on Saturday, 12 November 2011 00:17:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:04 UTC