-
Notifications
You must be signed in to change notification settings - Fork 465
Add BigInt primitive number type #4677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
indeed, it's something we should add. note let f = function
| 1n
| 2n -> 0
| x -> Nativeint.add x 3n |
We don't need a special literal imho. |
i feel like special literals would be better (like |
It would make it perhaps slightly more convenient to do e.g. |
@yawaramin it would also be possible to avoid having to allocate a string - not that there's a noticeable difference in perforamance very much of the time, but i do believe it'd be slightly more idiomatic? idk |
This proposal is sorely needed IMO, we at least need a single type in pervasives for libraries to target to as a first step.
I disagree, literals are much more intuitive and much less error prone. Another +1 for why this is needed, Temporal will be landing in the coming months and parts of the API rely heavily on bigints: https://tc39.es/proposal-temporal/docs Compiler support would be great also for output size - |
@somebody1234 aren't strings interned by JS runtimes nowadays? And in any case, I doubt that calling the constructor like @tom-sherman anyone can send a PR for at least initial BigInt bindings even without a custom literal syntax. Just need to create a new module About 'frustrating experience', I'm not really seeing how it's worse than having to use e.g. |
The |
@yawaramin interned... sure. whether the runtime would optimize that into a bigint constant... i don't know. of course as i basically mentioned before, it'd also be more "idiomatic" - as in, in js nobody uses |
@tom-sherman OK but the parsing of the literal has to happen somewhere. Making it compile-time in ReScript would mean duplicating the BigInt literal parsing functionality that already exists in the JavaScript platform, making sure to duplicate all its possible quirks and edge cases, and keeping those up-to-date, otherwise when people run into edge cases they will be super confused why ReScript BigInt literal parsing behaviour is different than vanilla JS (small example that we can already see: ReScript parses Anyway, whether that's done or not, all I'm saying is that the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Too eager, stale bot! |
Resolved #6670 |
I'm surprised no one suggested this yet (the only other relevant issue I could find was #2903). Now that all major browsers and runtimes support it (ignoring IE which is EOL'd anyway), I guess it's about time to add it as a primitive number type.
1n
,9007199254740991n
+ - * / ** %
(The MDN doc shows a couple static functions too, but they're not yet supported on Safari, and I don't think they're that useful.)
The text was updated successfully, but these errors were encountered: