bitsets greater than 128 bits #6919
VictorSohier
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
Simply, my basic use case would be bitsets over all the values in a byte. 256 bits would be useful for things like tries over strings. Allowing for arbitrarily large bitsets would still be useful for things collecting Linux input.h enum values in a bitset. I'm pretty sure these aren't the only use cases that would crop up.
Describe the solution you'd like
Allowing fixed size integer arrays as a backing type for bitsets
Additional context
I suggest fixed size integer arrays specifically because they are already value types and already exist. As for why not a u/i256 type, I know GingerBill already gave his criticisms of it for Carbon and I don't want to suggest making such a mistake. I also believe this more flexible approach covers more use cases and already has precedence in bitfields. This would also allow for the coverage of even larger enums.
As for how this will behave with implicitly defined bitsets (i.e. no explicit backing data type), my suggestion would be to make it a compiler error if the defined set exceeds the size of an int on the target platform unless explicitly defined, but I'm also fine (though, not thrilled) with it being implied to be an integer array of native alignment which encompasses the range.
There is also the precedence of bitwise operations being able to operate over arrays in Odin. I think this would make larger bitsets less clunky.
Beta Was this translation helpful? Give feedback.
All reactions