[MLton-user] opaque types and ffi
Mon, 24 Nov 2003 15:21:28 -0500 (EST)
> > Taking the idea a bit further, perhaps it would be nice to have the type
> > be 'a pointer, with FFI allowed for any 'a.
> I don't see any reason why a programmer couldn't do this himself.
> type 'a pointer = MLton.pointer
You can't ensure as strong guarantees, because to appease the
type-checker, one needs to have the type definition in scope; but, the
type definition will then allow any two pointers to be considered equal.
I think what Tom was getting at was that it would be nice to have;
structure Lib1 :> sig type x type t = x MLton.pointer ... end
structure Lib2 :> sig type y type t = y MLton.pointer ... end
You can't use a Lib1.t where a Lib2.t is expected. One still want's
Lib1.t to be an FFI type, because maybe the author of Lib1 forgot a C
function that the programmer wants. Or, for reasons of modularity, it
would be nice to define Lib1.t functions outside of Lib1.
On the other hand, if you have the type definition and
structure Lib1 :> sig type x type t = x pointer ... end
structure Lib2 :> sig type y type t = y pointer ... end
then Lib1.t is exactly the same type as Lib2.t.