[ANN] BlockEnums another enums package

BlockEnums.jl is in the general registry.

I started this before I knew about EnumsX.jl, which has some overlap in features. A couple of useful features of BlockEnums are

  • You can define additional instances of an enum after defining the enum itself. For example you can do @blockenum MyEnum x1 x2 and then later @add MyEnum x3 x4.
  • You can define “blocks” of integers (these can be named) and add instances in a specified block. This allows you to group instance of your enum that share a property in the same block. This is meant to mimic subtyping in some way.

I should motivate the features. BlockEnums is supposed to supply some functionality of julia types and subtypes. I am using them in cases where you pull heterogeneous items out of a container and want to handle them without paying the cost of run-time dispatch.

julia> using BlockEnums

julia> @blockenum (Myenum, mod=MyenumMod, blocklength=10^6, numblocks=10)

# Following could also be `Base.Enum`
julia> @blockenum Myblockname Frobnosticating=1  NonFrobnosticating

julia> @addinblock Myenum Frobnosticating var1 var2
var2::Myenum = 2

julia> @addinblock Myenum NonFrobnosticating var3 var4
var4::Myenum = 1000002

julia> inblock(var3, NonFrobnosticating)
ERROR: UndefVarError: `var3` not defined

julia> inblock(MyenumMod.var3, NonFrobnosticating)

julia> inblock(MyenumMod.var1, NonFrobnosticating)