freeHaskellFunctionPtr

Manuel M. T. Chakravarty chak at cse.unsw.edu.au
Tue Jan 2 20:27:20 EST 2001


Fergus Henderson <fjh at cs.mu.oz.au> wrote,

> On 02-Jan-2001, Marcin 'Qrczak' Kowalczyk <mk167280 at zodiac.mimuw.edu.pl> wrote:
> > 
> > and even the ability to cast between data pointers and function pointers
> > is described as a common non-standard extension in ISO/ANSI C99.
> 
> That's true. ANSI/ISO C does not guarantee that a data pointer will
> fit in a function pointer or vice versa.
> 
> If you want something that could be either a data pointer or
> a function pointer, you need to use a union:
> 
> 	union {
> 		void *data;
> 		void (*func)(void);
> 	}

This means that we should not provide

    castFunPtrToPtr :: FunPtr a -> Ptr b
    castPtrToFunPtr :: Ptr a -> FunPtr b

Has anybody ever used these casts?  As long as `FunPtr' is
used for f.e.d., I don't see much use in these casts.  It
certainly doesn't make much sense to peek and poke an
address produced by f.e.d.

So, I propose to drop these two casts.  Objections?

Cheers,
Manuel




More information about the FFI mailing list