ANN: H98 FFI Addendum 1.0, Release Candidate 9

Manuel M T Chakravarty chak at cse.unsw.edu.au
Tue Jun 10 01:01:42 EDT 2003


Ross Paterson <ross at soi.city.ac.uk> wrote,

> On Sun, Jun 08, 2003 at 09:06:07PM +1000, Manuel M T Chakravarty wrote:
> > Ross Paterson <ross at soi.city.ac.uk> wrote,
> > > On Wed, Jun 04, 2003 at 11:09:43PM +1000, Manuel M T Chakravarty wrote:
> > > > StablePtr are used to export references to Haskell values to
> > > > C, where they are treated as abstract data.  In C one
> > > > traditionally uses (void *) for that purpose (see "man
> > > > qsort(3)").  We want to make sure HsStablePtr is not to wide
> > > > to be passed as an argument to C functions expecting such
> > > > abstract types (such as qsort(3)).
> > > 
> > > How does HsStablePtr differ from HsDouble in this respect?
> > > (except that the C side can do even less with
> > > HsStablePtr.)
> > 
> > HsDouble is guaranteed to be one of C's floating types;
> > hence, all operations on floating types can be applied on
> > values of type HsDouble.
> 
> I meant to say that you can't pass an HsDouble to a "polymorphic" C
> function expecting (void *), so why should you be able to pass an
> HsStablePtr?  

Because HsStablePtr (in contrast to HsDouble) is used to
pass abstract Haskell values to C routines, so that they can
pass them around, store them, and pass them back to Haskell.
C routines that are meant to handle abstract values usually
use (void *).

Manuel



More information about the FFI mailing list