Comment on My first verified imperative programparentComments−alternatex1yNot sure if types are supposed to protect against overflow/underflow, it's more in the arithmetic territory. Interesting idea though, I wonder if some programming language allows overflow/underflow checks directly in the types.−Joker_vD1yYes, it's actually quite easy: +: (int<N>, int<N>) -> int<N+1> // or (int<N>, bit) as the return type *: (int<N>, int<N>) -> int<2*N> etc. Those are the actual types of those arithmetic operations.
Comments
Not sure if types are supposed to protect against overflow/underflow, it's more in the arithmetic territory. Interesting idea though, I wonder if some programming language allows overflow/underflow checks directly in the types.
Yes, it's actually quite easy:
etc. Those are the actual types of those arithmetic operations.