> On 16-Feb-2000, Simon Marlow <[EMAIL PROTECTED]> wrote:
> >
> > The easiest way is to declare mmap as a foreign function
> using foreign
> > import, then build a little wrapper around it.
> Unfortunately you won't be
> > able to turn the resulting memory into an array (even a
> ByteArray), since
> > these are assumed to live in GHC's heap
>
> I'm curious: why do you make that assumption?
>
> If I write code that defines some big array whose contents are known
> at compile time, it would be nice if ghc would allocate that array
> at compile time, in read-only memory, rather than allocating it on
> the heap at run-time.
No deep reasons I think: it just means augmenting our intermediate language
with the concept of static arrays, and propagating this through the
compiler.
Detecting the static-ness of an array is quite hard though, since there's
lots of abstraction between the original haskell array and the actual
primitives. Haskell's "array" calls the primitive newArray# to initialise
the array, and then fills it in using foldr over the element list - we'd
have to spot that the contents are static and replace the whole thing with a
static array.
Cheers,
Simon