mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
Arbitrarily sized ints #328
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bioball on GitHub (Jul 29, 2025).
The current
Intis an int64. We should support ints that are arbitrarily sized.One open question here is: should Pkl's numbers be arbitrarily sized? Or should we introduce a new type, e.g.
BigInt?@odenix commented on GitHub (Aug 14, 2025):
What are the use cases, and how common are they?
Retrofitting
Intwould be a breaking change and might affect runtime and memory performance. It might also increase the likelihood of writing erroneous programs that don’t terminate in a reasonable time.@bioball commented on GitHub (Aug 14, 2025):
One use-case is to represent IPv6 addresses, which are 128-bit ints.
@odenix commented on GitHub (Aug 14, 2025):
Shouldn’t these be represented by an
Ipv6stdlib class in any case?@bioball commented on GitHub (Aug 14, 2025):
Yeah, possibly. Right now this is implemented as a package, and backed by a u128 class; that effort is one of the motivations for this issue.
Another use-case here is to represent epoch microseconds.
@StefMa commented on GitHub (Aug 14, 2025):
The documentation of u128 is 🥇!
@odenix commented on GitHub (Aug 14, 2025):
FWIW, Java classes such as
java.time.Instantdon’t useBigIntegeranywhere (justlongandint).By the way, if Pkl’s
Intwas retrofitted to be arbitrarily sized, the Java code generator would need to generateBigInteger.