[[Extensible]]and Proxies (Was: Proxy.isProxy )

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Jul 13 10:30:21 PDT 2011


Tom Van Cutsem wrote:
> Aren't arrays [[Extensible]]:true by default?
Yes, but any array object can be set to [[Extensible]]: false and the implicit delete behavior defined in 15.4.5.1 for when length is set to a smaller value still applies.   To emulate that behavior at least the set/defineProperty traps need to work even when [[Extensible]] is false.
> 
> As to why the restriction, this is to uphold the following invariants (from
> ES5 section 8.6.2):
> 
> - If the value of the host object‘s [[Extensible]] internal property has
> been observed by ECMAScript code to be false, then if a call to
> [[GetOwnProperty]] describes a property as non-existent all subsequent calls
> must also describe that property as non-existent.
> 
> - The [[DefineOwnProperty]] internal method of a host object must not permit
> the addition of a new property to a host object if the [[Extensible]]
> internal property of that host object has been observed by ECMAScript code
> to be false.
> 
> - If the [[Extensible]] internal property of that host object has been
> observed by ECMAScript code to be false then it must not subsequently become
> true.


Yes, but the restriction prohibits otherwise legal behavior that doesn't violate the invariant.  Isn't that as "bad" as not enforcing the invariant?

Allen




More information about the es-discuss mailing list