On Wed, Nov 07, 2007 at 10:10:16PM +0000, Jules Bean wrote:
> Joel Reymont wrote:
> >Is there such a thing as memory-mapped arrays in GHC?
> 
> In principle, there could be an IArray instance to memory-mapped files.
> 
> (There could also be a mutable version, but just the IArray version 
> would be useful).

The IArray instance would be unsafe, however, because the contents of the
file could change after you opened it, breaking referential transparency.
I don't know what all is possible with file open modes, but I don't think
you can guarantee that once you've opened a file it won't change (unless
you unlink it, and know that noone else has an opened file handle to it).
It may be that by opening it in write mode you could ensure that noone else
modifies it (although I don't think this would work e.g. on nfs), but then
you eliminate the very useful possibility of mmapping read-only files as
IArrays (e.g. to access /usr/share/dict/words).

So it seems reasonable that the mutable version would necesarily be
primary, with the IArray version accessible only by an unsafe operation.
-- 
David Roundy
Department of Physics
Oregon State University
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to