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

On Nov 6, 2009, at 5:43 AM, P T Withington wrote:

> On 2009-11-05, at 19:42, Maciej Stachowiak wrote:
>
>> My claim is that Data is not much like these things. I believe it  
>> is more like String. It happens to be a sequence (of a very  
>> specific type), but it's specialized enough to be worth treating  
>> differently. Do people often regret that String is not an Array?
>
> Data is like an 8-bit "null encoded" String.  Which makes me wonder  
> if you really just want to extend String to allow different encodings.

Not for the Data use-cases.

Strings are used for binary data, which is tying our hands in  
supporting UTF-16 properly. Separate issue but we should not  
complicate String further IMHO.


>  But I also regret String not being and Array.

I agree with Maciej that having mutating methods be no-ops or throwers  
strongly suggests we not mix Array and String directly. Being able to  
apply non-mutating Array methods to string (primitive, even) arguments  
is ok. Splitting a string into an Array and mutating, then joining --  
very ok. But I don't see why you want String to *be* (is-a) an Array.


> Others must have too, because at one point I'm sure there was a  
> proposal to make [] on string mean charAt?

David Flanagan beat me to it: in ES5 and most browsers.

/be

Received on Friday, 6 November 2009 18:48:32 UTC