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

Brendan Eich brendan at mozilla.com
Sun Jun 23 13:19:45 PDT 2013


Brendan Eich wrote:
> Axel Rauschmayer wrote:
>>>> Array.prototype.move = function move(target=0,source=0, 
>>>> count=this.length-source)
>>>> Is the case of moving trailing elements somewhere else very common? 
>>>> If not, then I’d define the parameters in this order: source, 
>>>> count, target.
>>>> Rationale: easier to memorize.
>>>
>>> No, assignment-expression LHS/RHS (target/source) order precedent 
>>> wins for memorization (see Object.extend precedent, strcpy, memcpy, 
>>> etc.).
>>
>> That makes sense, thanks!
>>
>> I was thinking System.arraycopy, which may not a good precedent:
>> http://docs.oracle.com/javase/6/docs/api/java/lang/System.html#arraycopy%28java.lang.Object,%20int,%20java.lang.Object,%20int,%20int%29 
>>
>
> You lost me at "oracle.com/java..." :-P.

Joking aside, the weaker (source, target) order-precedent is from 
bcopy(3) in BSD Unix. I don't know for sure, and the signatures differ 
in other ways, but bcopy may have influenced Java's System.arraycopy design.

/be

>
> /be
>
>>
>> -- 
>> Dr. Axel Rauschmayer
>> axel at rauschma.de <mailto:axel at rauschma.de>
>>
>> home: rauschma.de <http://rauschma.de>
>> twitter: twitter.com/rauschma <http://twitter.com/rauschma>
>> blog: 2ality.com <http://2ality.com>
>>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the es-discuss mailing list