> Le 28 janv. 2015 à 09:58, Jordan Harband <ljh...@gmail.com> a écrit :
> 
> Typically, implementation-specific things aren't specified in the spec (like 
> Math precision, etc) - although usually when it's implementation-specific, 
> it's explicitly noted as such ( 
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-date.parse 
> <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-date.parse> , 
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.hypot 
> <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.hypot> , 
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-number-type
>  
> <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-number-type>
>  , https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys 
> <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys> , etc)
> 
> Strings are only defined in ES6 as a "primitive value that is a finite 
> ordered sequence of zero or more 16-bit unsigned integer" ( 
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-terms-and-definitions-string-value
>  
> <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-terms-and-definitions-string-value>
>  ) and are not noted as having any implementation-specific or 
> implementation-dependent qualities.
> 
> To me, "finite" here means `Number.MAX_VALUE` - ie, the highest number I can 
> get before I reach Infinity. An alternative reading is "any number greater 
> than zero that's not Infinity" - but at that point an implementation conforms 
> if it's max length is 1, which obviously would be silly.
> 

To me, "finite" is just to be taken in the common mathematical sense of the 
term; in particular you could have theoretically a string of length 10^10000. 
But yes, it would be reasonable to restrict oneself to strings of length at 
most 2^52, so that `string.length` could always return an exact answer.

—Claude

> However, Chrome 40 and Opera 26-27 have a limit of `0xFFFFFF0` (`2**28 - 
> 2**4`), Firefox 35 and IE 9-11 all have a limit of `0xFFFFFFF` (`2**28 - 1`), 
> and Safari 8 has `0x7FFFFFFF` (`2**31 - 1`). There's many more browsers I 
> haven't tested of course but it'd be interesting to know how wide these 
> numbers deviate.
> 
> 1) Should an engine's max string length be exposed, like `Number.MAX_VALUE`, 
> as `String.MAX_LENGTH`? This will help, for example, my `String#repeat` 
> polyfill throw an earlier `RangeError` rather than having to try to build a 
> string of that length.
> 2) Should the spec require a minimum maximum string length, or at least be 
> more specific in how it defines "finite"?

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to