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

Re: ArrayClass should imply @@isConcatSpreadable

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Mon, 28 Oct 2013 17:50:22 -0700
Cc: Boris Zbarsky <bzbarsky@MIT.EDU>, "public-script-coord@w3.org" <public-script-coord@w3.org>, es-discuss <es-discuss@mozilla.org>
Message-Id: <A3E337AD-5261-4166-84F3-8F52C09D2119@wirfs-brock.com>
To: Domenic Denicola <domenic@domenicdenicola.com>

On Oct 28, 2013, at 5:25 PM, Domenic Denicola wrote:
> I think the issue is that these things are properties, either because of web legacy (as in some specifications) or because the spec writers conceptualize them as such and are reluctant to change them (for the newer specifications). And returning a fresh array from the getter each time is unpleasant. If they could be changed to methods, returning a new object each time makes a lot of sense.
> That said I feel like this is a common enough need that it might be worth the DOM speccing a read-only proxy-onto-an-array view type that they could reuse. As Boris says it would probably be very similar to what ArrayClass does, so maybe ArrayClass is OK as-is, but I feel like fleshing it out in terms of real ES proxies would make it feel less hackish, perhaps?
> (Such a type would be generally useful for not just DOM specs, IMO. Maybe I should work on a library prototyping this and if it's awesome and everyone loves it and uses it, someone can spec it officially.)

So what's so onerous about returning a fresh array from the getter each time it was called.  If it was implemented in Es6, it would just be:
    return Array.from(internal_compy);

Proxies aren't cheap. Unless these arrays tend to be quite large, I wouldn't be surprised if the overhead of using a Proxy for this useless ended up being higher than the cost of making fresh arrays. 

Received on Tuesday, 29 October 2013 00:50:58 UTC

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