freeHaskellFunctionPtr

Marcin 'Qrczak' Kowalczyk mk167280 at students.mimuw.edu.pl
Wed Jan 3 07:46:37 EST 2001


On Wed, 3 Jan 2001, Fergus Henderson wrote:

> By "they", I mean the Haskell routines under discussion.

OK, I always thought that Haskell's FFI docs should document what they
assume about the C implementation which is not guaranteed by ISO/ANSI.

For example that pointers are physically amorphic, i.e. that
sizeof (int *) == sizeof (char *), and that
    void poke1 (int **p, int *x) {*p = x;}
    void poke2 (int **p, int *x) {*(char **) p = (char *) x;}
are equivalent, etc. - this follows from the existance of
    instance Storable (Ptr a)

foreign export dynamic is not implementable portably at all. This is a
different kind of assumption - Haskell's FFI assumes that there exist a
way do implement this on the C implementation in question. Usually it is
processor-specific (unless the C implementation provides some generic
means which would allow that - I haven't heard of it and gcc does not
provide them).

-- 
Marcin 'Qrczak' Kowalczyk





More information about the FFI mailing list