John J Barton wrote:
On Mon, May 28, 2012 at 10:09 PM, Allen Wirfs-Brock
<al...@wirfs-brock.com>  wrote:
On May 28, 2012, at 10:03 PM, John J Barton wrote:

So let's rewind to my original question.  If the discussion about SES
is leading us toward more things like freeze(), let's do a better job
this time.

John, could you xplain what you would have done differently with "freeze()".  
It's water under the bridge, but perhaps if you can explain what you would have done we 
will be better able to understand your concerns.

I would ask that the bar for the "freeze()" feature include exceptions
on modifications. If this is not feasible, the feature cannot be
accepted.

The reason JS in 1995 had quirks such as silent failure on attempt to assign to a non-writable property was lack of try-catch. ES3 added try-catch, so you have a point: ES5 could have made attempting to extend a non-extensible object always throw, irrespective of whether the attempt was from strict mode code.

However, in that case attempts to assign to non-writable existing properties on a non-extensible object (frozen object) would still not throw when made from non-strict code, unless ES5 changed the logic for assignment to an existing property to check both [[Extensible]] and [[Writable]]. If I can even try to recall those days, this seemed inconsistent and illogical. Why should assignment

  obj.foo = 42;

fail with a thrown exception for obj = Object.freeze({}) and obj = Object.freeze({foo:0}) but not for obj = {}; Object.defineProperty(obj, 'foo', {value:0})? All three ways of creating obj should either throw on the obj.foo = 42 attempt, or not throw.

So the heavy hand of pre-ES3 (pre-try-catch) primeval JS still hangs over the language.

I don't think this is as bad as you seem to think it is. Why not always "use strict"; at the top of your code, live long, and prosper?

/be



If, as seems to be the case, the exceptions are only possible once ES
mandates "use strict", then freeze() must wait for that fine day.

I believe that is a sensible model.

jjb

Allen

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to