david.bruant at labri.fr
Tue Mar 22 14:12:21 PDT 2011
Le 22/03/2011 21:42, David Bruant a écrit :
> 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, '*').
> In ES5, the String constructors (String and new String) both are
> expected to be used with zero or one argument, so using a two argument
> constructor should not break the web or people's expectations.
I have faced the problem of generating a string with length n while
thinking on the problem of "for a given object, how to generate a string
which isn't the name of one of its own properties?"
One solution was to use a Cantor-diagonal-like strategy.
The other solution I've come up with is to take all property names, take
the maximum length of it and generate a string with this length + 1.
Since it's a problem I have faced and there is a strawman for it, I
thought it could be interesting to discuss how to solve the "string
generation" problem, even though not really frequent.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss