| 08:43 | <eemeli> | My understanding of where we got to in post-meeting discussions this week with Jesse and nicolo-ribaudo is that an Amount ought to hold a mathematical value (as defined in '262), parsed from a string input value using the same method as for ToIntlMathematicalValue ( value ), but without support for non-finite values or -0. Amount would either have no built-in limits on the value, or it would match the limits imposed by Intl.NumberFormat. Overall, the intent would be to avoid defining a new numeric type beyond what's already in the spec, even if not easily accessible by users. |
| 09:29 | <Jesse> | that's my understanding as well -- thanks for sketching it out |
| 09:31 | <Jesse> | there's also an understanding that, if decimal were to advance, intl limits might also have to be adjusted (to account for the full range of decimal128, i.e. up to 34 significant digits and exponent of +/-6144), and ergo amount's limits |
| 10:06 | <eemeli> | Thinking on what we discussed, I'm kinda tending towards suggesting that we initially propose Amount with no built-in limits on the numerical value, like what's done with BigInt. Then we would only get rounding if fractionDigits or significantDigits were set in the options. |
| 13:35 | <sffc> | Implementations have their own harder limits. MVs are themselves unlimited, but they are usually bounded when creating an MV from a Number or elsewhere. The ICU4X limit is on the order of 2^16 digits and +/- 2^15 power of ten. |
| 13:35 | <sffc> | I think we should try for Stage 2 with some limit, perhaps the Intl.NF limit, and we can work out exactly what limit during Stage 2 |
| 13:39 | <Jesse> | agree -- for now, the spec text I'm working on is working with unlimited mathematical values |
| 13:44 | <sffc> | One of my biggest regrets about the Temporal design is that we chose limits for things that make it painful to implement. We spend so much time trying to optimize the 64+32 bit ints we need to represent nanoseconds since epoch for 100,000+ years. |
| 13:52 | <eemeli> | During lunch today I joked about defining a tagged template literal for Decimal, but tbh it doesn't look too bad. Here's one of the Decimal readme examples:
|
| 13:53 | <nicolo-ribaudo> | https://jsr.io/@nic/decimal-literal |
| 13:57 | <eemeli> | Is there a reason why that's not being considered for the spec? |
| 13:59 | <sffc> | I think we eventually want 1.2m but that should return a primitive. It would be surprising for 1.2m !== 1.2m with object-based decimals. |
| 14:01 | <eemeli> | You presumably meant this?
|
| 14:01 | <sffc> | I think it would be cool to have a decimal-based template syntax, where everything gets converted into a decimal.
|
| 14:02 | <eemeli> | That's what I have above and Nicolo in his decimal-literal? but with ${...} rather than some implicit access to the local context. |
| 14:02 | <sffc> | Yes right |
| 14:05 | <sffc> | This type of template syntax has a special place for me. When I was first learning to program, when I was about 10, I was having problems with number math in ActionScript, and I drafted what a solution would look like, and what I came up with looks remarkably similar to this. It was my first ever proposal. 😅 |
| 14:07 | <sffc> | I will make the observation that we don't actually need Decimal in order to implement the template syntax. It could use Math.decimalAdd as I suggested in issue 181, and return a Number. |
| 14:11 | <sffc> | We don't need to add Decimal if:
desugars to:
|
| 14:15 | <sffc> | A nice property of this direction is that we could have a Decimal mode, a Rational mode, a mode for finance, a mode for scientific computing, etc. We're not limited to Decimal128 and the arcane decisions it makes. |
| 14:33 | <Jesse> | is there any advantage to having this in the spec vs. as an external add-on? |
| 14:34 | <sffc> | JSSugar can implement the syntax so long as the primitives like Math.decimalAdd are in the standard library |
| 14:36 | <sffc> | Jesse, is your +1 about "the syntax is JSSugar's problem" or "we should expose primitives like Math.decimalAdd" |
| 14:37 | <Jesse> | my +1 was to the idea that such syntax would be JSSugar's problem |
| 14:38 | <Jesse> | imo Math.decimalAdd etc. could be considered as fallbacks in case a class-based Decimal fails |
| 14:39 | <Jesse> | but my sense of the temperature poll last week was that most people who follow this topic do want decimal as we've designed it (modulo the discussion of amount & where it should exist) |
| 14:40 | <Jesse> | (I think at one point I even experiemented with Math.decimalAdd etc. when things were looking especially bad with decimal. This was maybe 1.5 years ago) |
| 14:42 | <sffc> | I would really like to resolve issue 181. You posted a good comment on March 12, https://github.com/tc39/proposal-decimal/issues/181#issuecomment-2718669257, which I responded to, but you haven't responded back. |
| 14:46 | <Jesse> | I whipped up some WIP experiments with Math.decimalAdd to illustrate the issue, generating random ASTs that do arithmetic and comparing the results of doing the math as numbers vs. as decimals, but never commited it |
| 14:47 | <sffc> | Basically I think there needs to be a cohesive statement about why we think (Also, we never got around to updating the problem statement. The README is still out of date.) |
| 14:47 | <Jesse> | there's still an in-flight PR for that: https://github.com/tc39/proposal-decimal/pull/195 |
| 15:34 | <ljharb> | JSSugar isn't a thing (that was just chrome's nonviable idea for how to solve the shared problem), what do you mean "JSSugar's problem"? |
| 15:40 | <sffc> | Math.decimalAdd: https://developer.mozilla.org/en-US/play?id=vek0wYSHAUnyHe8nHoV1zLHZgmVluKk6XRjBkEG7Sj44JoN3yW03iumZ138KzrWN%2Baf0rWVYx4Af8B1j |