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 in the common case only. The description of `Array#slice` for example, does not use a default parameter in the signature and is accurate (assuming you read "the length of the array" as `ToLength(this.length)`).
On Tue, Feb 18, 2014 at 10:32 AM, Claude Pache <claude.pa...@gmail.com> wrote: > I think that the intent of this algorithm is clear despite its Cobol-like > language. Actually, for step 3, the spec uses the equivalent of: "If `k` is > `undefined`, let `relative` be `default` and go to step 5"; moreover, that > step is omitted when `default` is 0. This difference seem to have no effect, given that step 2 asserts that `default` is an integer between `0` and `len`. > steps 6 to 8. Let `to` be IndexFromRelativeIndex(`target`, `len`, 0). > ReturnIfAbrupt(`to`). > steps 9 to 11: Let `from` be IndexFromRelativeIndex(`start`, `len`, 0). > ReturnIfAbrupt(`from`). For greater precision, you might want to specify `+0` as the default here, to match the result specified for `ToInteger(undefined)`. --scott _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss