[Haskell-cafe] Int is broken [Was: Different answers on different machines]
Tommy Thorn
tt1729 at yahoo.com
Sun Jun 2 23:24:15 CEST 2013
On Jun 2, 2013, at 14:13 , Kata <lightquake at amateurtopologist.com> wrote:
> 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
More information about the Haskell-Cafe
mailing list