Binary data (ByteArray/ByteVector) proposal on public-script-coord
oliver at apple.com
Thu Nov 5 22:21:50 PST 2009
On Nov 5, 2009, at 10:14 PM, David-Sarah Hopwood wrote:
> Oliver Hunt wrote:
>> On Nov 5, 2009, at 4:01 PM, David-Sarah Hopwood wrote:
>>> Charles Jolley wrote:
>>>> This looks like a good approach. I wonder if the Data/DataBuilder
>>>> distinction could be handled better by using the Object.freeze()
>>>> semantics. Even if the browser does not support freezing in the
>>>> sense yet, you could borrow the ideas for data.
>>>> Probably the wrong API names, but here is the basic idea:
>>>> -> returns a mutable form of the Data object
>>>> Data.prototype.freeze() or Data.freeze(aDataObject)
>>>> -> makes the Data object frozen if it is not frozen already
>>>> -> returns the data object but pre-frozen. For Data object's
>>>> frozen can return "this"
>>>> Data.prototype.frozen - true when frozen, false otherwise.
>>> I don't know why we wouldn't just use Object.freeze. It is not
>>> unreasonable to require support for the ES5 APIs as a prerequisite
>>> for the Data type.
>> I disagree here -- i believe mutable vs. immutable data is different
>> from unfrozen and frozen objects [...]
> Why? What would the hypothetical Data.prototype.freeze do that would
> different to applying Object.freeze to a Data object?
>> (though i agree that the function names
>> freeze and frozen are just asking for problems in conjunction with
>> :D ). There are plenty of times where I would want to provide
>> data (the UA sharing content, etc), but i may still want to modify
>> object itself.
> Oh, you mean that you want *read-only* Data objects backed by a
> array. That is not the same thing as an immutable (or "frozen") Data
No, the issue here is that Charles has conflated object freezing with
immutable data, frozen objects and immutable data are not the same
thing -- for instance in the DOM I cannot set indices of a NodeList,
but the NodeList does not need to be frozen.
It is perfectly reasonable to have raw data that is immutable without
wanting the object that represents it to itself be immutable.
> David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
> es-discuss mailing list
> es-discuss at mozilla.org
More information about the es-discuss