[MLton] FFI types

Stephen Weeks MLton@mlton.org
Thu, 12 May 2005 21:49:25 -0700


> which consist of the code
> 
>         fn NONE => null
>          | SOME str => ?cast-string-to-t? str
> 
> where  ?cast-string-to-t?  is  something  that  give  you  a  MLton.Pointer.t
> pointing to the first character of its string  argument  (and  similarly  for
> refs, arrays and vectors).

It's not safe to cast from a string to a MLton.Pointer.t on the SML
side because a GC might happen between the time you cast and the time
the MLton.Pointer.t gets used.  I think the cast really has to happen
on the C side.