
On Jun 2, 2013, at 14:13 , Kata
In addition to Haskell already having an arbitrary-width integer type called Integer
But I wasn't asking for arbitrary-width. I was asking for explicit failures (overflow) rather than C-like silent corruption.
, consider the case where you have some program that basically boils down to
f :: Int -> Int f x = {- some super-complicated mathematical expression -}
f can only have bounds checks eliminated if the values of the inputs are known in advance. How often are you really going to know that? If you do something like
1. I said "minimize the cost of the overflow checking", I didn't say anything about bounds checking elimination. A conditional branch on the overflow from an add is nearly zero cost as it predicts perfectly and can be issued in parallel with all other instructions. Even better, some architectures (eg. SPARC) have overflow checking variants with zero overhead. And yes, for many instances it's trivial to see that overflow can't happen. 2. Even if that wasn't the case, I never want to sacrifice safety for a trivial perf overhead (for that stuff I use C). Tommy