.min / .max raises a larger question:
Should there be struct "constants"?
So
type Foo struct {
...
}
const Foo.pi = 3.0;
...
func f64 Foo.pie_c(f64 r) { return Foo.pi * r * 2; }
If so, then enums simply emit const TheEnum.min = ...; const TheEnum.max = ...;
Regarding the enum values... it's extremely common to use X macros to actually do that anyway - to generate the switch automatically with whatever you want. For example you might define:
#define types \
X(i8, 8, true) \
X(u8, 8, false) \
X(i16, 16, true) \
X(u16, 16, false) \
/* ... etc */
bool isSigned(type t) {
switch (t) {
#define X(a, b, c) case a: return c;
types;
#undef X
}
This occurs a lot when writing protocols or parsers, but also when describing simple state machines. Anytime you have enums really.
Associated values is the simplest way I know to express this (and it's a fairly small addition that has extremely powerful effects, consider
type enum State [char*(int) action] i32 {
START(startFunction) = 0,
END(endFunction)
}
state.action(10); // Calls startFunction(10)
It's not really important HOW it is implemented, just that it is there. The downside of the X macro solution in C is that it's very messy for IDEs to parse and it's also hard to read the code to know what happens (just look at Clang!)