3 ms·
You can do with a sum type (enum) that is represented by a u32 (repr(u32)), or converts into one. Though I don’t know Ada so can’t speak to how accurately I’m c
by efnx 3y ago
You can do with a sum type (enum) that is represented by a u32 (repr(u32)), or converts into one. Though I don’t know Ada so can’t speak to how accurately I’m creating the analogy.
- pjmlp 3y agoIn Ada/Pascal/Modula-2/Modula-3/.... it would be something like, type Subrange = 56..100; Colors = (Red, Green, Blue); Pixel = array [Colors] of byte; With the plus that it is a compiler error if an invalid value is assigned, and can be validated at compile time (or it will be a range runtime error otherwise).