Manuel M. T. Chakravarty
Thu, 14 Dec 2000 11:48:13 +1100
Simon Marlow <firstname.lastname@example.org> wrote,
> > Why is `foreignPtrToPtr' not exported from `ForeignPtr'
> > although it was specified to be exported in SimonM's
> > ``Proposal #1: ForeignPtr'' email?
> I don't remember conciously deciding not to export it, but I notice the
> ForeignObj version is deprecated.
> We should decide whether it is needed: do you have a use for it that
> can't be replaced with withForeignPtr? It seems that touchForeignPtr
> isn't a great deal of use without foreignPtrToPtr either.
The combination of foreignPtrToPtr and touchForeignPtr is -
at least - valueable for FFI tool generated code (in
particular, I want them for the new version of C->HS). It
might often be possible to replace their use with
withForeignPtr, but for machine generated code it seems
simpler to use the more elementary routines. The added
benefit here is that FFI tools don't have to rely as much on
the optimisation capabilities of the targeted Haskell
compiler (ie, that the compiler will inline withForeignPtr
So, if it is ok with everybody, I would change the export
Moreover, should we annotate routines like withForeignPtr
with an INLINE pragma or does GHC guarantee to inline code
like this anyway? Personally, I feel that in such
situations, we should always explicitly annotate the code
with INLINE pragmas rather than relying on some implicit
information about the inner working of the inliner and its
heuristics, which may change any time.
So, if nobody minds, I will change that, too.