> 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 method signature.)

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 the ES5 style, where we look at `arguments.length` instead
of using default parameters in the signature.  But it does use
`ToLength(this.length) - 1` as a default value; I think that could be
changed to `ToInteger(this.length) - 1` for consistency without
affecting actual behavior.

The `copyWithin`, `fill`, and `lastIndexOf`, `subarray` methods of
%TypedArray%.prototype are spec'ed with default arguments equal to
`this.length`, but there's no way `length` can be negative there, I
think  (offtopic: ...although I'd really be much happier if the
generic Array methods could be written to special-case %TypedArray% in
the proper way so that we could observe DRY instead of cloning most of
the algorithm descriptions).

 --scott
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to