[MLton-user] opaque types and ffi

Tom 7 twm@andrew.cmu.edu
Mon, 24 Nov 2003 15:26:47 -0500 (EST)


Well, take the following example:

functor Void () :> sig type t end = struct type t = unit end;
structure V1 = Void();
structure V2 = Void();

type file = V1.t;
type dir = V2.t;

val f = _ffi "fopen" : string * string -> file MLton.pointer ;
val g = _ffi "opendir" : string -> dir MLton.pointer ;

The range types of f and g are inequal, but with

type 'a ptr = MLton.pointer

file ptr and dir ptr are the same type, since their definitions are
expanded to just MLton.pointer. As Matthew noted before, abstract types
cannot be passed to or generated by ffi calls.

I'm not sure if it's worth the complication, since ffi is unsafe anyway.
But I think it does add expresive power over what's there now.

 - Tom

>
> > 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
>
> _______________________________________________
> MLton-user mailing list
> MLton-user@mlton.org
> http://www.mlton.org/mailman/listinfo/mlton-user
>
>


[ NEW! : http://tom7.org/       ]
[ OLD! : http://fonts.tom7.com/ ]