"not a Date object" vs. "not an object with [[Class]] of ''Date''"

Dmitry A. Soshnikov dmitry.soshnikov at gmail.com
Sat Oct 2 07:17:19 PDT 2010


  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
>



More information about the es-discuss mailing list