2011/10/7 John J Barton <[email protected]>

>
>
> On Fri, Oct 7, 2011 at 9:16 AM, Quildreen Motta <[email protected]>wrote:
>
>> 2011/10/7 John J Barton <[email protected]>
>>
>>>
>>>
>>> On Fri, Oct 7, 2011 at 8:34 AM, Axel Rauschmayer <[email protected]>wrote:
>>>
>>>> If you do something like
>>>>      var fuz = Object.extend(foo, {paper:'in', shoes:'my'});
>>>>
>>>> Then fuz will get all properties of Object.prototype, again, as
>>>> duplicates. In the above, you are clearly most interested in what you see 
>>>> in
>>>> the literal and those are the own properties.
>>>>
>>>
>>> I don't understand how you can get properties as duplicates in JS.
>>> I disagree, since in my example I specifically point out that fuz.bar()
>>> should work.
>>>
>>
>> You can't get duplicate properties, because keys are unique. However,
>> you'll still get loads of clutter in the target object. Also, again, I'm not
>> sure the majority of the use-cases would be concerned with copying the
>> properties in the whole prototype chain -- that's expensive! -- and you
>> could achieve the latter easily by recursively extending the object.
>>
>
> Again I'll ask you to consider that fuz.bar() should work. That is what
> extend means.  How can we solve this?
>
> We don't need to flatten the prototype chain, we can extend it.
> Object.extend(a,b) can return an object whose own properties are the own
> properties of |b| on those of |a| and the prototype chain of |b| appended to
> the prototype chain of |a|, dropping duplicate prototypes.
>

I believe that would be solved more effectively with traits (Self traits, I
haven't had the time to read JS's proposal on that yet).
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to