freeHaskellFunctionPtr

Fergus Henderson fjh at cs.mu.oz.au
Wed Jan 3 05:12:54 EST 2001


On 03-Jan-2001, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
> Wed, 03 Jan 2001 12:27:20 +1100, Manuel M. T. Chakravarty <chak at cse.unsw.edu.au> pisze:
> 
> > This means that we should not provide
> > 
> >     castFunPtrToPtr :: FunPtr a -> Ptr b
> >     castPtrToFunPtr :: Ptr a -> FunPtr b
> 
> It does not mean that, because existing C libraries are usually
> non-portable and some do require using such casts, however meaningless
> they could be.

Well, if they are left, then at very least they should be
very clearly documented as being non-portable.

> > Has anybody ever used these casts?
> 
> Yes: me, for the readline library.

Could you be more specific?
Which part of the readline library?
Why was the cast needed?

> But it's used to pass either a function pointer cast to a data pointer
> or a real data pointer to a function, together with an enumeration
> value indicating which one is this. Ugly, but that's life.
> 
> Another example is dlopen.

I think you mean dlsym().

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.




More information about the FFI mailing list