I'm not really sure what I think about all this. I try to always insert
assertions before operations like this, which makes me think the nicest
solution would be if the compiler errors out if it detects a problematic
expression that is unchecked...
uint diff(uint begin, uint end)
{
return end - begin; // error
}
uint diff(uint begin, uint end)
{
assert(begin <= end);
return end - begin; // ok because of the assert
}
I'm not going to get into how this would be implemented in the compiler,
but it sure would be sweet :)