[Haskell-cafe] Error in array index.
Jason Dusek
jason.dusek at gmail.com
Wed Jun 24 13:51:59 EDT 2009
2009/06/24 Daniel Fischer <daniel.is.fischer at web.de>:
> Am Mittwoch 24 Juni 2009 18:50:49 schrieb Jason Dusek:
> > 2009/06/24 Ketil Malde <ketil at malde.org>:
> > > So in effect, you have a zero-length underlying array, but
> > > the array implementation still keeps track of the real
> > > indices and tries to print some contents. (Correct?)
> >
> > I don't quite understand your reasoning here.
>
> The 'length' of the array, as in 'number of elements' is
> calculated by multiplying the lengths in each dimension
>
> [...]
>
> I don't know if that's how it's implemented, but that's the
> reasoning leading to an array of size 0.
That seems reasonable, actually. My system is nominally 64bit
(it's MacIntel) but the kernel claims `i386` so there we are.
It's too bad that indexes are `Int` instead of `Word` under
the hood. Why is `Int` used in so many places where it is
semantically wrong? Not just here but also in list indexing...
Indices/offsets can only be positive and I can't see any good
reason to waste half the address space -- yet we encounter
this problem over and over again.
This problem probably runs pretty deep. Just having a flexible
"backing index type" is only part of the issue, since pointer
indexing operations work with `Int` as well. If you wanted to
hide all this stuff, you'd need to segment particularly large
unboxed arrays...
--
Jason Dusek
More information about the Haskell-Cafe
mailing list