On 28 May 2012 06:37, John J Barton <[email protected]> wrote:
> A library writer creates an object in one scope and all of their tests > succeed. I use it another scope and my code fails. We are both using > legal statements. How can this not be a global effect? > You're both using legal statements in the mode (variant) of the language that _you_ have chosen to use in your execution context. JavaScript has always had read-only properties (ex: Object.prototype, Function#length, Number.MAX_VALUE), and prior to ES5 always had writes to read-only properties fail silently. Object.freeze, Object.defineProperty, and the like give us new ways to _create_ read-only properties, but read-only properties are neither new nor do they create a new "global effect." Silent write failures are a Bad Thing(tm), so strict mode lets us opt into receiving exceptions when we try to assign to read-only properties. This is _local_ to our execution context, where we have chosen (implicitly or otherwise) to use non-strict or strict mode. Nothing global there either. I dislike object.freeze() > altogether, not because it's a bad idea but because it's not a > JavaScript idea. But I didn't realize how truly horrible it was until > I discovered that it is silent and that silence is modal. > Perhaps that mistake is done. For my money, the far bigger mistake would be to have different kinds of read-only properties: Ones that fail silently for legacy reasons, and one that throw even in non-strict mode. Far better to have a consistent view of read-only properties within a given execution context, where the author decides whether they want silent failures or exceptions. -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

