

Typically, implementationspecific things aren't specified in the spec (like Math precision, etc)  although usually when it's implementationspecific, it's explicitly noted as such ( https://people.mozilla.org/~jorendorff/es6draft.html#secdate.parse , https://people.mozilla.org/~jorendorff/es6draft.html#secmath.hypot , https://people.mozilla.org/~jorendorff/es6draft.html#sececmascriptlanguagetypesnumbertype , https://people.mozilla.org/~jorendorff/es6draft.html#secobject.keys , etc)
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.
However, Chrome 40 and Opera 2627 have a limit of `0xFFFFFF0` (`2**28  2**4`), Firefox 35 and IE 911 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"?
_______________________________________________
esdiscuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/esdiscuss


Typically, implementationspecific things aren't specified in the spec (like Math precision, etc)  although usually when it's implementationspecific, it's explicitly noted as such ( https://people.mozilla.org/~jorendorff/es6draft.html#secdate.parse , https://people.mozilla.org/~jorendorff/es6draft.html#secmath.hypot , https://people.mozilla.org/~jorendorff/es6draft.html#sececmascriptlanguagetypesnumbertype , https://people.mozilla.org/~jorendorff/es6draft.html#secobject.keys , etc)
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 2627 have a limit of `0xFFFFFF0` (`2**28  2**4`), Firefox 35 and IE 911 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"?
_______________________________________________
esdiscuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/esdiscuss


Strings can't possibly have a length larger than Number.MAX_SAFE_INTEGER  otherwise, you'd be able to have a string whose length is not a number representable in JavaScript. So, at the least, I think it would make sense to define a maximum string length as Number.MAX_SAFE_INTEGER, even if that provides no guarantees that strings of that length will work (ie, OOM errors etc are fine), whether it's exposed on String or not.
It might also be nice if the spec included a nonnormative note that suggested a lower bound for a maximum string length (where strings are guaranteed to work), so that at least there's a guideline.
Thoughts?
_______________________________________________
esdiscuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/esdiscuss


From: esdiscuss [mailto: [hidden email]] On Behalf Of Jordan Harband
> Strings can't possibly have a length larger than Number.MAX_SAFE_INTEGER  otherwise, you'd be able to have a string whose length is not a number representable in JavaScript.
So? That's a bit inconvenient, but no reason to argue that such a string can't exist.
_______________________________________________
esdiscuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/esdiscuss


It's not a requirement, it's a definition. But more on the point, the length of a String is simply a nonnegative integer, not a Number value representing such a integer. Not to be confused with the value of the "length" property of that String, which is necessarily a Number value. _______________________________________________
esdiscuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/esdiscuss

