On Oct 7, 2011, at 9:23 AM, Axel Rauschmayer wrote:

> ...
>>  
>> I would prefer the name Object.copyOwnPropertiesTo(source, target) or 
>> Object.copyOwnTo(source, target) to the name “extend” (which, to me, 
>> suggests inheritance).
>> 

I isn't clear from the attribution who said the following.  It wasn't Axel:

>> Since we live in a right to left world (a = b();) we need the target on the 
>> left. Then multiple RHS also works easily.

There is probably a significant part of the world population who would disagree 
with this assertion.  We have building technology for web developer across the 
entire world. We need to be careful about using cultural bias to justify 
language design decisions.

You might have a stronger argument is you said that  JS already has a right to 
left bias and that consistency is important.  




> 
> Swapping the parameters would is fine with me, then the name should probably 
> be changed to something like copyOwnFrom(target, source).
> 
>> However, note that if Object.create() were fixed:
>>    var clone = Object.create(Object.getPrototypeOf(orig), 
>> Object.getOwnProperties(orig));
> 
> I don’t see a simple way of “fixing” (property descriptors do have their 
> uses) Object.create(). But, in a way, the proto operator <| is that fix.
 or, an extended new operator:

       clone = new orig

or .{

depending upon the exact use case.  However, the key thing is that things like 
<|, .{, and possible extensions to new are intended to be directly used in 
application code for very common use cases  Things like 
    Object.create(Object.getPrototypeOf(orig), 
Object.getOwnPropertyDescriptors(orig))
are best encapsulated within library functions that are simply named to address 
some specific usecase.

> However, your are on to something with the above which will work as follows 
> in ES.next:
>    var clone = Object.create(Object.getPrototypeOf(orig), 
> Object.getOwnPropertyDescriptors(orig));

Except that things like [[Super]] bindings and private named keys significant 
complicate the matter. 

Allen



_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to