-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
enum bit masks #2988
enum bit masks #2988
Conversation
I don't love the name, but the functionality is useful. I'm thinking we should spend some time and energy on the enum stuff and get the API right. That was just something I banged out one day. |
@JeffBezanson @StefanKarpinski Thoughts? OK to merge? |
I would prefer to have this in base and with a better name. |
$(esc(:(Base.start)))(x::Type{$(esc(T))}) = $(esc(:(Base.start)))($vals) | ||
$(esc(:(Base.next)))(x::Type{$(esc(T))},s) = $(esc(:(Base.next)))($vals,s) | ||
$(esc(:(Base.done)))(x::Type{$(esc(T))},s) = $(esc(:(Base.done)))($vals,s) | ||
$(esc(:(Base.length)))(x::Type{$(esc(T))}) = $(length(vals)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the enum type iterable seems very strange. Why not just provide a values(::Type{Enum})
function that provides a copy of the values array? Or maybe values should be stored as a tuple, which will be both immutable and iterable.
Tentatively marking as 0.2.x |
This is a feature. Features are bad. |
adds additional syntax, functions, supertype, bugfixes to enums: @enum X a b c=1 d=2 @enum_mask Y a b c d
6c7c7e3
to
1a4c02f
Compare
The pure enum functionality here has been updated and merged in #10168, I guess the enum bitmask portion is still up for debate. |
Should we close this? Do we really have a strong use-case for this in Base? |
This introduces a macro
@enum_mask
similar to@enum
. However, rather than linear indexing, it uses powers of 2, and allows the standard c-style flag / mask manipulations.Thoughts? Is this the right approach? Should it be turned into a package now?