Ok, here's also implemented meta-constructor. Constructors created by this meta-constructor may produce also objects with specified [[Class]]. Additionally I made a sugar with inheriting from passed "className.prototype" object.
It may be found here: http://gist.github.com/607668 Again, non-standard __proto__ is used to inject the needed prototype (however, at implementation level it doesn't matter). Dmitry. On Mon, Sep 6, 2010 at 6:17 PM, Dmitry A. Soshnikov < [email protected]> wrote: > On 02.10.2010 17:29, Brendan Eich wrote: > >> On Sep 6, 2010, at 1:43 AM, Dmitry A. Soshnikov wrote: >> >> For what to create a proxy? It's only for catch-traps (yes, it may be >>> used additionally to create a _catcher_ with "Array" [[Class]], but without >>> additions -- i.e. if a user wants just to inherit from Array.prototype and >>> to have all arrays' stuff -- proxies are not needed to him). >>> >> Proxies are required to update length to be one greater than index >> (property name-string P such that ToString(ToUint32(P)) == P and ToUint32(P) >> is not 2^32 - 1) when setting an indexed property. Array's magic [[Put]] is >> not inherited. >> >> > Yep, true, but if we have ability to specify the [[Class]] -- we'll have > overloaded [[DefineOwnProperty] (or [[Put]] in ES3). > > Here's this ad-hoc (with using __proto__ injection) implementation: > http://gist.github.com/607668 > > By the way, at first glance, the ability to specify [[Class]] with using > first level of inheritance is not so convenient and needed. Because with the > same success we may create a simple array and augment it with needed > properties. However, starting from the second and later inheritance levels > -- it may be convenient. > > This is if to talk about prototypal inheritance. If to consider class-based > inheritance (that is, with using constructors), possibly it can be sense in > the special meta-constructor (a constructor of constructors) which may > specify, objects of what kind (of what [[Class]]) a newly created > constructor may produce. > > P.S.: in addition, the Proxy constructor may also accept className > parameter. But repeat -- proxies are needed to trap the property access. If > a user just want to have Array.prototype in inheritance chain and at the > same time have an object of the "Array" kind, he just creates it with > specifying this kind. He don't need to write a proxy's handler for that. > Howerver, if he does need the catcher -- he creates a proxy of "Array" kind. > > Dmitry. > > /be >> >> >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

