Agoric / nat

Ensures that a number is within the natural numbers (0, 1, 2...) or throws a RangeError
Apache License 2.0
5 stars 4 forks source link

Add support for BigInt #10

Closed katelynsills closed 4 years ago

katelynsills commented 5 years ago

We need to add support for BigInt.

erights commented 5 years ago

Yes. In fact, once we verify that BigInt exists on all our target platforms, we should consider incrementing the major version number and switching Nat to only emit BigInts. For that version, an open question:

Should Nat also continue to accept the numbers it accepts now, making it into a coercer, or should it only accept BigInts, preserving its nature as a pure verifier? If a coercer, should we change its name to BigNat?

erights commented 4 years ago

In fact, once we verify that BigInt exists on all our target platforms

Verified. We should switch to BigInt soon and stop worrying about exceeding the SAFE_INTEGER range of floats.

katelynsills commented 4 years ago

Great, let's add this to our todo lists

katelynsills commented 4 years ago

Question: Should we allow numbers and BigInts or only BigInts?

It seems like we can support both. My main worry was that supporting both would encourage inadvertent coercion between BigInts and numbers if both are valid Nats, but it appears that any operations including both throw a TypeError.

erights commented 4 years ago

All extents that represent integers or natural numbers should be switched all the way to only BigInts. We should not try to support both BigInt and Number. Now that we have a monorepo, it'll be interesting to see if we can avoid a transitional phase where we temporarily support both.

katelynsills commented 4 years ago

Ok, great. I think the transitional phase should be smooth since this repository isn't part of the monorepo, so we can simply make sure to make this a major change as per semver and then the various packages in the monorepo can choose when to upgrade on a per package basis

katelynsills commented 4 years ago

Closed by #112