Assigning to ReadOnly properties

Brendan Eich brendan at
Mon Nov 12 09:05:21 PST 2007

On Nov 12, 2007, at 9:00 AM, Jonathan Watt wrote:

> Hi,
> As I understand it the reason assignment to ReadOnly properties  
> fails silently
> is that there was no try-catch prior to ECMAScript 3.

Right. Netscape 2 reported a fatal error, but during ES1  
standardization we agreed to go with silence is (golden|deadly).

> Could/will edition 4 require an exception to be thrown in strict mode?

Overtly incompatible, also highly desirable. So opt-in versioning  
could enable this, but it's one more migration headache (see recent  
exchange between Mark Miller and myself). An alternative would be a  
pragma of some sort:

   use readonly error

or perhaps

   use readonly throw

We try to make pragmas more readable, sometimes with an extra word;  
not sure this is the best way to phrase it still, but the idea would  
be to enable throwing of a ReadOnlyError on assignment to a ReadOnly  
property. Comments?


More information about the Es4-discuss mailing list