On Tue, Dec 23, 2008 at 07:44:14PM -0500, wren ng thornton wrote: > AFAIK, Data.Word.Word is defined to be "the same size as Prelude.Int" > (which it isn't on GHC 6.8.2 on Intel OS X: 32bits vs 31bits) and Int is > defined to be at least 31bits but can be more. My interpretation of this > is that Int and Word will generally be implemented by the architecture's > natural word size in order to optimize performance, much like C's "int" > and "unsigned int" but with better definition of allowed sizes. This > seems to be supported by the existence of definite-sized variants Word8, > Word16, Word32...
Of course, natural word size can mean 'natural pointer size' or 'natural int size'. Which are different on many architectures. So, you want to be careful about which you want. > So yeah, I'm meaning the machine word, but I think Word is intended to > proxy for that. Maybe I'm wrong, but provided that Word contains (or can > be persuaded to contain) a round number of Word8 and that operations on > Word are cheaper than the analogous sequence of operations on the Word8 > representation, that's good enough for my needs. If you want to find out the 'natural' sizes, then look at the 'CInt', 'Ptr', and 'FunPtr' types, which follow the C 'int' 'void *' and 'void (*fn)()' types. So they will conform to the architecture ABI for the underlying spec/operating system. If you just want a type guarenteed to be able to hold a pointer or an integer, use 'IntPtr' or 'WordPtr' which are provided for just that case. John -- John Meacham - ⑆repetae.net⑆john⑈ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe