Mark S. Miller (2013-07-14T14:25:21.000Z)
domenic at domenicdenicola.com (2013-07-17T19:00:43.566Z)
On Sat, Jul 13, 2013 at 8:46 PM, Brendan Eich <brendan at mozilla.com> wrote: > We should just add > > http://wiki.ecmascript.org/doku.php?id=strawman:bignums > > to ES7. First, I wholeheartedly agree. JS is increasingly being used as a target of compilation. When I asking people doing so what they biggest pain point is, the lack of support for integers is often the first thing mentioned. That said, there are the usual open issues we'll need to settle, most of which aren't even raised by this strawman. Most important is the same as one of the objections raised about decimal: If we treat each individual new primitive type as a one-off special case, we're digging ourselves a deeper abstraction mechanism hole. We first need something like value proxies, so we understand how unprivileged libraries would define new numeric types -- complex, rational, matrix. Once we understand what the bignum API would look like were it defined by an unprivileged library, we can proceed to add it as a primitive anyway. We can even do so before actually accepting a value proxy proposal if necessary, as long as we've settled what the use-API would be. Is there a corresponding wrapping type? How does this wrapping type relate to Number? I think the pragma is a bad idea but not a terrible idea. The problem is that we have no choice that a floating point number that happens to have an integral value prints as an integer. Given that, it would be confusing to read simple integer literals into a different type. Should bignums toString with the i suffix? In general I would say yes. The biggest argument that they should not is that we should be able to use bignums to index into arrays. Contradicting myself above, if we do support such a pragma, we should also have a JSON.parse option that reads integers into bignums, and one that prints only bignums as integers. This JSON option would also print all floats using only float notation. Were we not introducing TypedArrays until ES7, would we have typedArray.length be a bignum rather than a floating point number? If so, is there anything we can do in ES6 to leave ourselves this option in ES7?