On Oct 1, 2010, at 6:24 PM, Oliver Hunt wrote:

> I really don't like the idea of using proxies simply to essentially create an 
> array with a custom prototype.

Implement proxies, then we'll talk :-P.


> My understanding of what is wanted (in terms of subtyping an array) is an 
> ability to have something like
> 
> var arr = new MyArray()
> 
> Where 'new MyArray' behaves in essentially the same manner as 'new Array', 
> however it produces an object along the lines of
> 
> <an array instance> <- <a custom prototype> <- <array prototype>

I don't think the use-case is satisfied by a direct Array instance, whatever 
its proto. That's the rub.

/be

> 
> In a engine that support mutating proxies this would be equivalent to:
> 
> function MyArray() {
>    var result = Array.apply(null, arguments);
>    result.__proto__ = MyArray.prototype;
>    return result;
> }
> 
> MyArray.prototype = Object.create(Array.prototype);
> 
> If my understanding of this desired behaviour is correct, i think a better 
> solution would be to make an API that could generate the MyArray function.
> 
> --Oliver
> 
> 
> On Oct 1, 2010, at 6:14 PM, Brendan Eich wrote:
> 
>> KangaX brought this up in
>> 
>> http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/
>> 
>> and proxies are of no avail. To make an array-like using ES5 is possible but 
>> [[Class]] won't lie, and that is still true with Proxy.create instead of 
>> Object.create.
>> 
>> As we have discussed, [[Class]] is very much a nominal type tag, so it is 
>> not something we want to be forged by an impostor. But perhaps as Allen 
>> mentioned in the TC39 meeting this week, [[ClassName]] could be separated 
>> from [[Class]], and forged without problem. Proxies would want to be able to 
>> present a specific [[ClassName]], but a non-varying one -- so probably a 
>> trailing Proxy.create parameter. Thoughts?
>> 
>> /be
>> 
>> 
>> 
>> _______________________________________________
>> es-discuss mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/es-discuss
> 
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss

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

Reply via email to