A module has an enum type A
and I want to export all its instances instances(A)
.
I want to write a macro @export_instances
like
module MyModule
export A
@enum A a b c
@export_instances A
# `export a, b, c`
end # module
I have read Julia documentation’s metaprogramming page and Export enum - #4 by mathieu17g. I was able to implement the following function to return the expression to export all instances of an enum type T
.
function export_instances(T)
:(export $(Symbol.(instances(T))...))
end
Then, I have tried to write the desired macro but can’t. How do I?