Dispatch on enum

Note that this forces Julia to do a runtime dispatch in general (unless x is a compile-time constant), which is slow. Julia’s dispatch is really optimized for code in which the types are mostly inferred (constants) at compile time.

If you have runtime data in an @enum, you should probably be using if statements or similar, rather than dispatching on Val, or you should alternatively be re-thinking your code structure to put the information in the type domain to start with.

6 Likes