-
-
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
1-based @enums #28351
Comments
x-ref: #10168 (comment) |
thanks, I see, that this has been discussed extensively, I'll just close this. |
You certainly have to question any change that only requires 2 more characters to get the desired behavior: @Fruit apple banana orange vs. @Fruit apple=1 banana orange |
the other way round one could argue that it would only take 2 more characters to turn a Julia-consisten (1-based) enum into a C compatible enum (0-based) @enum Fruit apple banana orange vs. @enum Fruit apple=0 banana orange |
Why does this alleged form of "consistency" matter? |
I don't think it's a big deal. |
It might matter if you could have enums acting as array indexes. I wanted this functionality and created an Perhaps Of course this might be a bit of a stretch. Julia-0.6.4> @IntEnum Regions north east south west
IntEnum Regions:
north = 1
east = 2
south = 3
west = 4
Julia-0.6.4> sales = zeros(Float64, length(Regions))
4-element Array{Float64,1}:
0.0
0.0
0.0
0.0
Julia-0.6.4> for region in Regions
sales[region] = rand(0:50000)/100
end
Julia-0.6.4> for region in Regions
println(region, " ", sales[region])
end
north 66.19
east 129.88
south 409.46
west 200.81 |
As julia has 1-based arrays, shouldn't enums also be 1-based? Maybe interoperability with C code weights more more important in this case?
The text was updated successfully, but these errors were encountered: