Solving the drawbacks of @enum

taotree
Wed, 12 Jan 2022 19:12:03 +0000
New to Julia

So, @enum is causing me major problems:

I can’t use the names I want to use because it puts the names directly in the namespace. I need to go back and forth between strings and enums easily.

Override Base.show for enums doesn’t appear to work.

I don’t want to put it in a little module by itself to namespace it because I can’t use that same name for both the module and the enum which causes confusion that I have to use X for type but Y.z for values.

I found this online: Encapsulating enum access via dot syntax But that results in allocations just to reference MyEnum.value

I don’t need nor want the values in the type system, so that’s not an option.

Is there a good solution for enums that I’m missing?

16 posts - 7 participants