-
Notifications
You must be signed in to change notification settings - Fork 1k
SIP-26: Unsigned Integers #548
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
Conversation
Imported from scala/slip#30
Rather than go through in detail point by point, I'll start with a higher-level concern: this creates a new category of thingy which is neither a fully supported primitive nor an object. In particular we have
This means that rather than being a helpful stepping stone, an intermediate proposal creates the need for a variety of workarounds, which then will either fix in place this awkward not-fully-integrated scheme, or require a bunch of code changes again when things are no longer awkward. Because of this, and because of a lack of motivating examples for the extent of the integration so far, I'd recommend an even less integrated version of unsigned integer types: they are just AnyVal wrappers, and you give a UArray AnyVal type that presents the components as their unsigned counterparts. If it is uncomfortable to live with the limitations of AnyVal types, well, everyone else trying to use AnyVal types also has to live with those uncomfortable limitations. If those are fixed in a generally useful way, then everyone benefits. |
@Ichoran Thanks for your summary of the concerns you had expressed earlier. I'm almost on my way to vacation, so I'll come back to this end of August. |
@sjrd - I thought it bore repeating since the draft doesn't entirely address the issues even if it does acknowledge some of them. |
I agree with @Ichoran. While having unsigned numbers might be nice, I fear that the current technical limitations prevent us from having an implementation on the JVM that would make people even remotely happy. I feel that it would be better to wait until the JVM ships with value types and revisit this. The worst case would be to standardize something now, and then realize that it won't "upgrade" to JVM value types without breaking semantics and user code. |
Well ... I was trying to address the My efforts can be found here: scala/scala@2.12.x...sjrd:improve-equals-hashcode The closest I got with a complete implementation is a 6% performance hit on the 3 of those 6% are due to the changes in The remaining 3% are due to the changes to I guess this is the end of this SIP, given that:
Since I couldn't fix those performance, I haven't spent time trying to address the other comments. I'll leave this PR open until the next SIP meeting (Sep 13), since it's scheduled for discussion, at which point I guess the committee will officially reject it. |
Thanks for describing all your findings and results, @sjrd. We all appreciate the work you've put into this. |
Imported from scala/slip#30
By: Sébastien Doeraene @sjrd and Denys Shabalin @densh
tl;dr: We propose the addition of 4 "primitive" types to represent unsigned integers: UByte, UShort, UInt and ULong.
A prototype implementation of this proposal, with unit tests and benchmarks, can be found at scala/scala@2.12.x...sjrd:uints
For the non-tl;dr, read the complete text.