It's a bit surprising that Julia doesn't have built in enums and a case/switch form. I'm glad that there's open issue https://github.com/JuliaLang/julia/issues/5410 to address the lack of case/switch. Is there any hope that we may see these (or at least the built in case/switch) in 1.0?
On Tuesday, August 23, 2016 at 5:57:20 AM UTC-7, Stefan Karpinski wrote: > > Oh, I see that you have: > https://groups.google.com/forum/#!topic/julia-users/fgzVlbGcw-o. > > On Tue, Aug 23, 2016 at 8:55 AM, Stefan Karpinski <[email protected] > <javascript:>> wrote: > >> The formatting on that came out pretty garbled. Can you repost with line >> breaks and such? >> >> On Mon, Aug 22, 2016 at 5:03 PM, Paul Sorensen <[email protected] >> <javascript:>> wrote: >> >>> The following is my idea of writing enums that are better than the macro >>> because they give you a typesafe way of passing them to a >>> functionbaremodule EnumName immutable enumname x::UInt8 end >>> const Value_A = enumname(0) const Value_B = enumname(1)end# usage >>> examplebaremodule Color immutable color x::UInt8 end const >>> Red = color(1) const Green = color(2) const Blue = color(3) const >>> White = color(4) const Black = color(5)endfunction >>> testColor(c::Color.color) println("A color was >>> passed")endtestColor(Color.Red) >>> >> >> >
