Bjoern Hoehrmann (2013-10-19T17:15:05.000Z)
* Allen Wirfs-Brock wrote:
>The utility of a hypothetical 'at' method is presumably exactly that of 'codePointAt'. 
>
>   str.at(p)
>would just be a convenience  for expressing
>   String.fromCodePoint(str.codePointAt(p))
>
>So the real question is probably, how common is that  use case.

Certainly not common enough to warrant a two-character method on the
native string type. Odds are people will use it incorrectly in an
attempt to make their code look concise, not understanding that it'll
retrieve a substring of .length 1 or 2, possibly consisting of a lone
surrogate, based on a 16 bit index that might fall in the middle of a
character; the problematic cases are fairly rare, so it's hard to
notice improper use of `.at` in automated testing or in code review.
-- 
Björn Höhrmann · mailto:bjoern at hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
domenic at domenicdenicola.com (2013-10-26T03:04:43.712Z)
Allen Wirfs-Brock wrote:

> The utility of a hypothetical 'at' method is presumably exactly that of 'codePointAt'. 
>
> ```js
> str.at(p)
> ```
>
> would just be a convenience  for expressing
>
> ```js
> String.fromCodePoint(str.codePointAt(p))
> ```
>
> So the real question is probably, how common is that  use case.

Certainly not common enough to warrant a two-character method on the
native string type. Odds are people will use it incorrectly in an
attempt to make their code look concise, not understanding that it'll
retrieve a substring of .length 1 or 2, possibly consisting of a lone
surrogate, based on a 16 bit index that might fall in the middle of a
character; the problematic cases are fairly rare, so it's hard to
notice improper use of `.at` in automated testing or in code review.