—Claude

Le 14 janv. 2013 à 20:46, Claude Pache <[email protected]> a écrit :

> 
> Le 14 janv. 2013 à 19:29, Kevin Smith <[email protected]> a écrit :
> 
>> 
>>> 
>>> The concept of freezing the "whole object" is the problem.  If you
>>> call `freeze` on a DOM object, does the page stop changing?  Of course
>>> not -- objects can have hidden state that you, the client of that
>>> object, have no access to and thus no way to freeze.  This isn't
>>> something new being added here.
>> 
>> Slots whose existence is guaranteed to be completely hidden from all code 
>> that does not possess a "magic key" looks new to me.
>> 
>> You can argue that the change is justified (that's the kind of argument I'd 
>> like to see in fact), but arguing that it "isn't something new" isn't 
>> working for me.
>> 
>> { Kevin }
>> 
>> _______________________________________________
>> es-discuss mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/es-discuss
> 
> Really, there is nothing new.

In fact, I meant: this sort of behaviour is already implemented in predefined 
objects, and symbols provide  a way to implement it *naturally* in user-defined 
objects (see below). So there is hopefully something new.

> Try this in your favorite ES5-compliant browser:
> 
> d = new Date(2000, 0, 1)
> Object.freeze(d)
> d // output: Sat Jan 1 2000 ...
> d.setFullYear(2001)
> d // output: Mon Jan 1 2001 ... Uh? the date was not frozen!
> 
> The value of the Date object is stored in some internal "slot", which is not 
> enumerable with Object.getOwnPropertyName or configurable with 
> Object.defineProperty, but only accessed by some ad-hoc API.
> 
> Symbols allow you to store protected properties (just like the date of a Date 
> object) in a natural manner, without resorting to some clever hack. And the 
> very definition of "protected" means that you can't access if you haven't the 
> key. It is really the raison d'être of symbols. 
> 
> —Claude
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to