Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-06 Thread Maciej Stachowiak
On Nov 5, 2009, at 5:14 PM, Charles Jolley wrote: I hadn't thought about freeze affecting all other values on the object. I agree that is not desirable. Still, having separate object types for mutable and immutable objects introduces a new pattern to JS. Why not follow the pattern used

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-06 Thread Maciej Stachowiak
On Nov 5, 2009, at 11:03 PM, David-Sarah Hopwood wrote: Oliver Hunt wrote: -- for instance in the DOM I cannot set indices of a NodeList, but the NodeList does not need to be frozen. NodeList objects are read-only. But the values they return may change over time due to factors other t

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Brendan Eich
On Nov 5, 2009, at 11:03 PM, David-Sarah Hopwood wrote: No, the issue here is that Charles has conflated object freezing with immutable data, That isn't conflation; they're the same. Not necessarily. Counter-example: a JS String object wrapping a JS string primitive is mutable but its char

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread David-Sarah Hopwood
David-Sarah Hopwood wrote: > Oliver Hunt wrote: >> On Nov 5, 2009, at 10:14 PM, David-Sarah Hopwood wrote: >>> Oliver Hunt wrote: I disagree here -- i believe mutable vs. immutable data is different from unfrozen and frozen objects [...] >>> Why? What would the hypothetical Data.prototype

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread David-Sarah Hopwood
Oliver Hunt wrote: > On Nov 5, 2009, at 10:14 PM, David-Sarah Hopwood wrote: >> Oliver Hunt wrote: >>> 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 be >> dif

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Oliver Hunt
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() semantic

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Charles Jolley
Why? What would the hypothetical Data.prototype.freeze do that would be different to applying Object.freeze to a Data object? For example, I might load an immutable JPG and then want to set: imageData.name = "someimage.jpg"; to help me keep track of what the data is. Freezing would prevent

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread David-Sarah Hopwood
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 freez

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Charles Jolley
I hadn't thought about freeze affecting all other values on the object. I agree that is not desirable. Still, having separate object types for mutable and immutable objects introduces a new pattern to JS. Why not follow the pattern used for freeze(), seal() and preventExtension()? Here's

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Maciej Stachowiak
Using the freeze pattern is an interesting possibility that I hadn't considered. Tentatively, I think having separate types for mutable and immutable is better than using freeze(). Here are my reasons: - It seems like it may be useful to have an immutable Data (one that doesn't let you ch

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Maciej Stachowiak
Added public-script-coord since discussion is happening here. On Nov 5, 2009, at 3:08 PM, Alex Russell wrote: On Nov 5, 2009, at 2:48 PM, Maciej Stachowiak wrote: I pulled together a rough proposal for representing binary data in ECMAScript and posted it on public-script-coord. I think ha

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Oliver Hunt
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 general sense yet

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread David-Sarah Hopwood
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 general > sense yet, you could borrow the ideas for data. > > Probably th

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Charles Jolley
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 general sense yet, you could borrow the ideas for data. Probably the wrong API names, but here

Re: Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Alex Russell
On Nov 5, 2009, at 2:48 PM, Maciej Stachowiak wrote: I pulled together a rough proposal for representing binary data in ECMAScript and posted it on public-script-coord. I think having this is important for many W3C specs, but it is probably best defined in ECMAScript. I'm posting a link h

Binary data (ByteArray/ByteVector) proposal on public-script-coord

2009-11-05 Thread Maciej Stachowiak
I pulled together a rough proposal for representing binary data in ECMAScript and posted it on public-script-coord. I think having this is important for many W3C specs, but it is probably best defined in ECMAScript. I'm posting a link here in case anyone is interested and is not on the pu