2 ms·
> Use subtyping in Julia and enums in Rust. I would use enums in Julia, making the enum you define a field of the PlayerClass: @enum PlayerStar Sol Pol Cent
by celrod 6y ago
> Use subtyping in Julia and enums in Rust.
I would use enums in Julia, making the enum you define a field of the PlayerClass:
@enum PlayerStar Sol Pol Cent
struct PlayerClass
star::PlayerStar
# other fields
end
Julia's compiler will split small unions into static dispatches behind branches, and can also decide whether or not to specialize on types or create a generic functions.
But if your code is performance sensitive, I'm more comfortable controlling the behavior than relying on these optimizations.
The problem is, dispatch is often a more convenient coding style than long branches.