> We might have discussed this previously, but what exactly do
> we know about the behaviour of expressions like
>
> toEnum 2 :: AddrOff
>
> and
>
> (fromInteger . toInteger) $ 2 :: AddrOff
>
> I mean what do we want to - or can we - guarantee? I think,
> this should be mentioned in the doc, because FFI tools need
> to use this functionality.
>
> [If we can get a consensus here as to what we want the
> guaranteed behaviour to be, I'll add it to the doc.]
I don't know why we have AddrOff at all.
I re-read the original discussion, and I just don't buy the arguments, which
went something along the lines of not assuming more than is guaranteed by
the C definition as regards pointers. That means we can't convert a pointer
to an integer and back again, and expect it to mean the same thing. Fine;
there's no way to do that using Addr.
Pointer arithmetic is different from arithmetic on integers, but it's the
*arithmetic*, not the *offset* that is architecture-dependent. Since sizeof
returns an Int, and (a `plusAddr` fromIntegral (sizeof x)) is guaranteed to
advance a to the next element in an array of 'x's, why can't we just drop
the fromIntegral? And then Manuel's question becomes moot.
Or am I missing something?
Cheers,
Simon