Wed, 03 Jan 2001 12:27:20 +1100, Manuel M. T. Chakravarty <chak@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.
Has anybody ever used these casts?
Yes: me, for the readline library.
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.
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. We could remove these casts, but they will be used anyway: they would have to be produced by wrapping a C function (relying on the implementation of both in terms of Addr forever might be not the best practice, especially if function pointers on IA-64 are 16 bits - I'm for 90% sure about this). -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK