W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2009

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

From: Maciej Stachowiak <mjs@apple.com>
Date: Fri, 06 Nov 2009 15:39:37 -0800
Cc: P T Withington <ptw@pobox.com>, public-script-coord@w3.org, es-discuss Steen <es-discuss@mozilla.org>
Message-id: <48EC01EE-03FE-463A-83AB-9355A55954D7@apple.com>
To: Alex Russell <alex@dojotoolkit.org>

On Nov 6, 2009, at 1:39 PM, Alex Russell wrote:

> On Nov 6, 2009, at 11:30 AM, Maciej Stachowiak wrote:
>
>>
>> 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.  But I also regret String not being and Array.  Others  
>>> must have too, because at one point I'm sure there was a proposal  
>>> to make [] on string mean charAt?
>>
>> ES5 does have bracket index access to the individual characters.  
>> But it does not make String inherit from Array.prototype, or add  
>> all of the Array methods. To make it more concrete, have you ever  
>> wished you could use methods like map(), filter(), reduce() or  
>> join() on a String?
>
> join's an oddball since it's effectively a no-op, but map() and  
> filter(), absolutely.

Can you give specific use cases for these, maybe with hypothetical  
code examples?

Join would not be a no-op, and indeed you can use Array.prototype.join  
on a String today:

javascript:alert(Array.prototype.join.call("abcde", "123")) ==>  
"a123b123c123d123e"

Not a no-op but I'm not sure it's useful.

Regards,
Maciej
Received on Friday, 6 November 2009 23:40:14 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:02 UTC