ES3 Specification oddness.

Mark S. Miller erights at
Sun May 18 20:10:00 PDT 2008

While making an editing pass over the ES3.1 draft spec, I came across
the following oddness inherited from the ES3 spec: [[Put]] (P, V)
             When the [[Put]] method of O is called with property P
and value V, the following steps are taken:
             1. Call the [[CanPut]] method of O with name P.
             2. If Result(1) is false, return.
             ....	[[CanPut]] (P)
             The [[CanPut]] method is used only by the [[Put]] method.
             When the [[CanPut]] method of O is called with property
P, the following steps are taken:
             1.	If O doesn't have a property with name P, go to step 4.
             2.	If the property has the ReadOnly attribute, return false.
             3.	Return true.
             4.	If the [[Prototype]] of O is null, return true.
             5.	Call the [[CanPut]] method of [[Prototype]] of O with
property name P.
             6.	Return Result(5).

As I read this spec, if object B inherits from object A, A has a
ReadOnly 'foo' property, and B does not have its own 'foo' property,
then this spec says that = ...

should fail rather than define an own 'foo' property on B. This seems
to imply that ReadOnly implies non-overrideable. (Curiously, Java used
the keyword "final" for both concepts, but that's just a coincidence.
In Java, it means one or the other depending on whether it applies to
a field or a method.)

Is this intended or a mistake? Do JavaScript implementations obey this
peculiar behavior? Do programs depend on it?


More information about the Es4-discuss mailing list