New ES6 strawman: Array.prototype.fill and Array.prototype.move
bkardell at gmail.com
Sun Jun 23 18:18:54 PDT 2013
On Jun 23, 2013 5:12 PM, "Allen Wirfs-Brock" <allen at wirfs-brock.com> wrote:
> 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_movefor 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.
> > — /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>
> > /be
> es-discuss mailing list
> es-discuss at mozilla.org
I would like to propose that .move() smells funny. It implies things that
are not so. It actually copies, and, while .copyRange suggestion from the
wiki is better, it really -feels- like .copySlice() which answers the args
question as well.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss