new ForeignPtr without finalizers

Manuel M T Chakravarty chak at cse.unsw.edu.au
Thu Jun 12 00:46:53 EDT 2003


Alastair Reid <alastair at reid-consulting-uk.ltd.uk> wrote,

> > I'd propose to
> >
> > * add `newForeignPtr_',
> > * reverse the argument order to `newForeignPtr', and
> > * reverse the argument order to `addForeignPointerFinalizer'
> >   (for consistency).
> 
> I agree with adding newForeignPtr_.  (Presumably the report would define 
> newForeignPtr in terms of newForeignPtr_ and addForeignPtrFinalizer.)
> 
> I'd prefer to avoid swapping the argument order because of code breakage.

I think, we all agree on adding `newForeignPtr_' (so, I'll
add that).  The reason why I suggested reversing the
argument order is that

  newForeignPtr_ :: Ptr a -> IO (ForeignPtr a)

and with *reversed* arguments also

  newForeignPtr myFinalizer :: Ptr a -> IO (ForeignPtr a)

In other words, it seem much more likely that one would
partially apply `newForeignPtr' to a finaliser than to a
pointer that is to be finalised.  But this is a minor point.

Manuel



More information about the FFI mailing list