[MLton] Callback to function pointer?

Henry Cejtin henry.cejtin@sbcglobal.net
Thu, 14 Jul 2005 13:26:24 -0500

You  have  to  be  careful  about  this:  not all C values are like refs.  Or
perhaps it is just that the C type isn't quite what people tend to  think  it
is.  If I have an array
    extern int      z[10];
then  the  symbol  z  is a contstant (not a ref) pointer to integers.  On the
other hand,
    extern int      *z;
means that z is a ref pointer to integers.  (All of this  was  really  nicely
handled in Algol-68.)

As to why you would want
    _address "symbol";
to  return  types other than MLton.Pointer.t, I would use this because I want
opaque types here (sometimes).

I don't like the idea that _import would do a fetch immediately for non-arrow
types  but  delay  it  to  the  call  for  arrow  types (if I understood that

Given that there is no way to make the read/write be a ref in ML (because the
code  for  !  and  := depend on the ML layout), I think that encoding them as
functions is correct.  This isn't needed in the case at the start  where  the
linker  symbol  really  is a constant, but only in that case.  You could only
tell that you are in this case if you let (required) the C type to carry that
information by having the type be (using C cast notation)
    (int [10])
    (int *)
and  that  would  have to be parsed by MLton.  I don't think that it is worth