Export enum



I am defining an enum such as @enum myenum enumname1 enumname2 in a module using Julia 0.6. it seems I have to explicitly export both enum type name(myenum) and enum elements(enumname1,enumname2). I know this way is more explicit, but usually we want all elements of an enum type be exported too. is there a way to just do export myenum so that type name and all its elements be exported, or should this behavior be the default for export enum?



Here’s a macro that does it:

macro exported_enum(name, args...)
        @enum($name, $(args...))
        export $name
        $([:(export $arg) for arg in args]...)

@exported_enum fruit apple banana


this macro is great, should be included in the base. thanks sharing.