JuliaLang/julia — pull request #5842 by filmackay (2014-02-18 04:22:31+00:00)
Title: @enum implementation

Here's an attempt to improve the @enum implementation (still in examples for now). You can do things like:
```julia
julia> include ("[..]/julia/examples/enum.jl")

julia> @enum Sort [:sortnone=>0, :sortasc=>1, :sortdesc=>2]

julia> convert(Cint, sortasc)
1

julia> include ("/src/julia/examples/enum.jl")

julia> @enum Sort [:sortnone=>0, :sortasc=>1, :sortdesc=>2]

julia> names(Sort)
3-element Array{Symbol,1}:
sortdesc
sortasc
sortnone

julia> convert(Cint, sortasc)
1

julia> sortnone
Sort(0)

julia> sortnone < sortasc
true

julia> sortnone == sortdesc
false

julia> convert(Sort, 1)
Sort(1)

julia> convert(Cint, sortdesc)
2
```
Issues:
- I seem to need to keep the symbol in the enum - so I can provide a better name for each value
- I originally had a type parameter to define the `Cint` equivalent used. Due to the complexity I decided to start with simple `Cint` first.

Feedback welcome :)