
On Sun, Apr 25, 2004 at 11:38:19PM +0200, Tomasz Zielonka wrote:
On Sun, Apr 25, 2004 at 04:12:25PM -0400, David Roundy wrote:
On the other hand, since they are still 32 bit computers, any given application can still only access 4G of memory. This issue will only be a problem on 64 bit platforms which have a 32 bit Int.
Here is a funny program that gives wrong result because of length returning Int on a 32-bit computer.
import Data.List main = print (length (genericTake 5000000000 (repeat ())))
Running it shows
$ ./A 705032704
But this is a strange piece of code and I agree that it will hardly be a problem on a 32 bit platform.
In fact, the only way this will be a problem is if your list is lazy and consumed by the length function, but it's hard to see how that could happen except in strange example code. That is, it's hard to imagine when you'd need to know the length of a data structure you don't need... A perhaps slightly less contrived example (although far slower) would be to try to write hFileSize as: hStupidFileSize f = do h <- hOpen f ReadMode length `liftM` hGetContents h which would give wrong results for large files. But of course this is why hFileSize returns Integer... -- David Roundy http://www.abridgegame.org