4 ms·
Personally, I really wish numeric types supported more than just unsigned/signed <minimum bit length>. Generic range types at a minimum, perhaps even "a type is
by TheLoneWolfling 12y ago
Personally, I really wish numeric types supported more than just unsigned/signed <minimum bit length>. Generic range types at a minimum, perhaps even "a type is defined by a pure function that returns true/false for if the value is a valid instance of that type" - want to specify that the input must be a Gaussian prime at compile time? Sure! (Or, for a saner example, want to specify that the input must be a normalized quaternion? Sure!)
For generic range types, you can just specify "this stores a number in this range" (with negative infinity/infinity being valid values for the bounds) and let the compiler figure out the best way to store it (with overrides, of course. Just because you have sane defaults doesn't mean you should make people fight the language). Especially if you could specify wrapping rules. Exception on under/overflow / wrapping / saturation / "won't happen" (read: compile-time error if the compiler can show that it can overflow/underflow) - exception being the default.