New ES6 strawman: Array.prototype.fill and Array.prototype.move

Allen Wirfs-Brock allen at wirfs-brock.com
Sun Jun 23 14:12:17 PDT 2013


On Jun 23, 2013, at 1:36 PM, Brendan Eich wrote:

> Allen Wirfs-Brock wrote:
>> See http://wiki.ecmascript.org/doku.php?id=strawman:array_fill_and_move for a strawman proposal for two new Array methods. These are proposed for inclusion in ES6.
> 
> I updated the wiki:
> 
> 
> Discussion
> 
> Q: Does anyone know of a rationale for why (start, end) might be a better design pattern than (start, count) for such operation?
> 
> A: Array.prototype.slice uses (start, end) where end is a fencepost to facilitate looping over half-open ranges within a larger range. Spec’ing count requires subtracting next_start - end, gratuitously. Also, consistency with slice and range APIs matters. This should be considered carefully in the design.

Yes, both start,end (slice) and start,count  (splice) currently appears in Array methods so it isn't obvious which precedent to follow for best consistency. I could go either way.  It would be nice to have a utilitarian-based argument for one or the other.  Search result was it because of the -1. 

allen





> 
> — /Brendan Eich <mailto:%26%23x62%3B%26%23x72%3B%26%23x65%3B%26%23x6e%3B%26%23x64%3B%26%23x61%3B%26%23x6e%3B%26%23x40%3B%26%23x6d%3B%26%23x6f%3B%26%23x7a%3B%26%23x69%3B%26%23x6c%3B%26%23x6c%3B%26%23x61%3B%26%23x2e%3B%26%23x6f%3B%26%23x72%3B%26%23x67%3B> 2013/06/23 20:31/
> 
> 
> /be
> 



More information about the es-discuss mailing list