Ross Paterson <[EMAIL PROTECTED]> 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. If a value of type "float" is passed to a function argument of type "double", the C compiler will insert automatic coercion code by way of C's argument promotion rules automatically. We cannot rely on such promotion rules for pointers. > You know it somehow corresponds to a pointer on the Haskell side, > but that doesn't seem relevant. There is no guarantee whatsoever that HsStablePtr is a pointer on the Haskell side. In GHC, stable pointers are integral indexes into a table of stable values. Cheers, Manuel _______________________________________________ FFI mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/ffi
