hervan / anaander

a turn-based strategy board game where all your units belong to a hive mind
https://hervan.github.io/anaander/
2 stars 0 forks source link

evaluate enums and variant types where applicable #21

Closed hervan closed 7 years ago

hervan commented 7 years ago

57c4637 started changing variants into enums as an experiment. enums can be used as numbers or strings, but as they can change places easily in javascript, it introduced some silent type errors in the code. investigate where stronger typing can be enforced in these cases, otherwise revert to use variants for a more static type. variant types should remain in code if their benefits can in fact be tapped, like pattern matching producing more concise code. otherwise enums can be used instead, mostly for their string values and ordering. try a hybrid approach, with enums as tags for unions, if possible.