Build Status Coverage Aqua QA JET QA

BlockEnums is like the built-in Enums. The main differences are

  • Enumerated types are mutable in the sense that instances may be added after the type is created.
  • The enumeration may be partitioned into blocks of values. For example @addinblock A 2 x would add the instance x to type A in the second block of indices.
julia> using BlockEnums

julia> @blockenum Fruit apple banana

julia> Fruit
BlockEnum Fruit:
apple = 0
banana = 1

julia> @add Fruit pear
pear::Fruit = 2

julia> Fruit
BlockEnum Fruit:
apple = 0
pear = 2
banana = 1

Some block features

julia> using BlockEnums

julia> @blockenum (Myenum, mod=MyenumMod, blocklength=100, numblocks=10, compactshow=false)

julia> @addinblock Myenum 1 a b c
c::Myenum = 3

julia> @addinblock Myenum 3 x y z
z::Myenum = 203

julia> BlockEnums.blockindex(MyenumMod.y)

Methods for functions in Base

Methods for the following functions in Base are defined and follow the established semantics.

  • cconvert
  • write, converts to the underlying bitstype before writing.
  • read , reads a value from the bitstype and converts to the BlockEnum
  • isless
  • Symbol
  • length
  • typemin, typemax These are the min and max of values with names bound to them.
  • instances
  • print


BlockEnums passes JET.jl and Aqua.jl tests.