On May 28, 2012 2:53 AM, "T.J. Crowder" <[email protected]> wrote:
>
> 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.

Unfortunately I am not successful in communicating the problem here.

In the example I described both variants are in the same 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."

How can changes to the object model in a language the supports passing
objects not be global?

You and I may both believe our JS is best, but if we share objects then
neither gets 1JS.

>
> 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.

Sorry I don't follow your logic here. I am arguing for more consistency.
1JS, not "author's choice".

jjb

> --
> 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

Reply via email to