Tue, 02 Jan 2001 19:40:11 +1100, Manuel M. T. Chakravarty <chak@cse.unsw.edu.au> pisze:
PS: It could be argued that `Ptr ()' can always be used instead of `Addr' and that therefore we should do away with `Addr' altogether. Opinions?
I agree that Addr uses should be replaced by Ptr and FunPtr (well, I thought it was obvious!).
Yup, I agree with all this. We should deprecate Addr in the interests of having as few interfaces as possible.
newForeignObj has been converted to Ptr, but since ForeignObjs themselves were later replaced with ForeignPtrs, it makes sense to let newForeignObj use Addr again as in previous released versions of ghc. For withForeignObj it could be done for consistency too (it's new so it does not really matter).
Sounds reasonable.
I would let freeHaskellFunPtr accept and ignore nullFunPtr, since I once had to write when (ptr /= nullFunPtr) $ freeHaskellFunPtr ptr and it can be seen as consistent with free.
This makes sense if nullFunPtr is really a valid value for a FunPtr. The FFI spec doesn't say anything about f.e.d. functions possibly returning nullFunPtr. I've always thought that C's free() accepting NULL as a valid argument was a questionable decision (although I have to admit it's convenient at times). Cheers, Simon