String.prototype.repeat

David Bruant david.bruant at labri.fr
Tue Mar 22 23:34:49 PDT 2011


Le 22/03/2011 22:29, Peter van der Zee a écrit :
> On Tue, Mar 22, 2011 at 2:39 AM, Dmitry A. Soshnikov
> <dmitry.soshnikov at gmail.com <mailto:dmitry.soshnikov at gmail.com>> wrote:
>
>     On 22.03.2011 23:42, David Bruant wrote:
>>     Hi,
>>
>>     About the string_repeat strawman
>>     (http://wiki.ecmascript.org/doku.php?id=strawman:string_repeat),
>>     one alternative solution could be a two argument constructor.
>>     Something like: String(n, pattern). So, for the example in the
>>     strawman, it would be String(3, '*').
>
>     A little bit off-topic, but not so big off-topic. Recently on
>     Twitter there was a question why it's not an array of zeros:
>
>
> Actually I think Array.fill or Array#fill should be added for one of
> the reasons for repeat: it is very likely that the host environment
> can iterate (or even optimize) a repeat/fill much much faster than the
> es interpreter could possibly achieve through looping. Especially with
> larger numbers.
>
> (I'm happy once we can use a native String#repeat :)
>
> Otoh, I don't think the second problem David points out (generate
> unique property names) should become part of the spec. Seems to me to
> be a rather obscure use case.
I agree. I solved that problem for testing purposes. Sorry if I was
unclear; I didn't mean to standardize this one. Just the string (and
array?) generation.

David

>
> - peter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110323/c8b7dd12/attachment.html>


More information about the es-discuss mailing list