Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-18 Thread Claude Pache
Le 17 févr. 2014 à 21:25, Brendan Eich bren...@mozilla.com a écrit : C. Scott Ananian wrote: But as you point out, I don't think there's any actual behavior change, since everything washes out to `0` at the end. It's just a matter of writing a clearer more consistent spec. Yet in that

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-18 Thread Claude Pache
Le 17 févr. 2014 à 22:32, C. Scott Ananian ecmascr...@cscott.net a écrit : Allen: I can volunteer to offload some of the work of auditing for similar cases with default arguments. From a quick read-through, only `Array#fill` seems to have the same issue. `Array#lastIndexOf` is written in

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-18 Thread C. Scott Ananian
I like this refactoring. This doesn't change the spec's behavior; this would be the first solution proposed in https://bugs.ecmascript.org/show_bug.cgi?id=2546 which was to rewrite the spec's non-normative text to make it clear that `end=this.length` in the signature was describing the behavior

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-18 Thread Brendan Eich
Claude Pache wrote: But I think that clarity can be improved by avoiding to obscure the intent by computation details. For my personal polyfill, I have found useful to abstract out the following steps, used (with slight variations) thrice in `Array.prototype.copyWithin` and twice in

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-17 Thread C. Scott Ananian
On Mon, Feb 17, 2014 at 7:08 AM, Claude Pache claude.pa...@gmail.com wrote: Just a last note. Beyond the philosophical aspect whether arraylikes of negative length make any sense at all, there is a strong technical issue you have probably overlooked: For array methods in general, and for the

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-17 Thread Brendan Eich
C. Scott Ananian wrote: But as you point out, I don't think there's any actual behavior change, since everything washes out to `0` at the end. It's just a matter of writing a clearer more consistent spec. Yet in that light you still have a point, I think. Allen? /be

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-17 Thread André Bargull
On 2/14/2014 11:40 PM, C. Scott Ananian wrote: On Fri, Feb 14, 2014 at 11:50 AM, André Bargull andre.barg...@udo.edu wrote: I think Scott is requesting this change: https://gist.github.com/anba/6c75c34c72d4ffaa8de7 Yes, although my proposed diff (in the linked bug) was the shorter, 12. If end

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-17 Thread Allen Wirfs-Brock
On Feb 17, 2014, at 12:25 PM, Brendan Eich wrote: C. Scott Ananian wrote: But as you point out, I don't think there's any actual behavior change, since everything washes out to `0` at the end. It's just a matter of writing a clearer more consistent spec. Yet in that light you still have

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-17 Thread C. Scott Ananian
It's not the same effect, because `lenVal` could be an object with valueOf/toString/@toPrimitive side-effects. Point taken. (Although I'm fine with invoking the side effects twice if you're using `this.length` as a default value, since that would be 'unsurprising' if you are looking at the

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-16 Thread C. Scott Ananian
On Fri, Feb 14, 2014 at 12:40 PM, C. Scott Ananian ecmascr...@cscott.net wrote: On Fri, Feb 14, 2014 at 11:50 AM, André Bargull andre.barg...@udo.edu wrote: I think Scott is requesting this change: https://gist.github.com/anba/6c75c34c72d4ffaa8de7 Yes, although my proposed diff (in the linked

Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-14 Thread C. Scott Ananian
For reference: https://bugs.ecmascript.org/show_bug.cgi?id=2546 `Array#copyWithin` has a (non-normative) signature of `(target, start, end = this.length)`. However, this is slightly misleading because the spec actually calls `ToLength` on `this.length` and then uses *that* for the default value

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-14 Thread Allen Wirfs-Brock
On Feb 14, 2014, at 12:46 PM, C. Scott Ananian wrote: For reference: https://bugs.ecmascript.org/show_bug.cgi?id=2546 `Array#copyWithin` has a (non-normative) signature of `(target, start, end = this.length)`. However, this is slightly misleading because the spec actually calls `ToLength`

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-14 Thread André Bargull
On Feb 14, 2014, at 12:46 PM, C. Scott Ananian wrote: / For reference:https://bugs.ecmascript.org/show_bug.cgi?id=2546 // // `Array#copyWithin` has a (non-normative) signature of `(target, start, // end = this.length)`. However, this is slightly misleading because the // spec actually

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-14 Thread Claude Pache
Le 14 févr. 2014 à 21:46, C. Scott Ananian ecmascr...@cscott.net a écrit : array-likes with negative length Array-likes with negative length doesn't make sense, or at least it isn't a useful concept as far as ECMAScript is concerned – as it doesn't make sense to consider arraylikes of

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-14 Thread C. Scott Ananian
On Fri, Feb 14, 2014 at 11:50 AM, André Bargull andre.barg...@udo.edu wrote: I think Scott is requesting this change: https://gist.github.com/anba/6c75c34c72d4ffaa8de7 Yes, although my proposed diff (in the linked bug) was the shorter, 12. If end is undefined, let relativeEnd be

Re: Changing behavior of Array#copyWithin when used on array-like with negative length

2014-02-14 Thread Claude Pache
Le 14 févr. 2014 à 23:40, C. Scott Ananian ecmascr...@cscott.net a écrit : Claude Pache wrote: Array-likes with negative length doesn't make sense. `Array.prototype.copyWithin.call({ length: -1 }, ... );` Call it whatever you like, although I'm always interested in learning new