[MLton] more FFI revisions
Stephen Weeks
MLton@mlton.org
Sat, 6 Aug 2005 10:21:07 -0700
> Looking at that, I think we ought to unify the treatment of the "*"
> forms. Here is one proposal, which I think has the nice property
> that applying a "*" form to a pointer yields precisely the type of
> the corresponding "non-*" form:
OK.
> I would way way prefer if you just specified the full type you get,
> even though it involves some duplication. After all, if that is
> painful then I can (or should) be able to use a type polymorphic
> type abbreviation for that.
Good point. Certainly have the ":" be like a type annotation will be
less confusing.
Combining these ideas together, one gets the following.
_address "symbol" : ptrTy;
_import "symbol" [cdecl | stdcall] : cfTy;
_import * [cdecl | stdcall] : ptrTy -> cfTy;
_export "symbol" [cdecl | stdcall] : cfTy -> unit;
_symbol "symbol" [alloc] : (unit -> cbTy) * (cbTy -> unit);
_symbol * : ptrTy -> (unit -> cbTy) * (cbTy -> unit);
This does break backward compatibility with _export, but I could see
that being reasonable. We could even detect, allow, and deprecate the
old usage for this release. So we would also have
_import "symbol" : cbTy; ==> cbTy (* DEPRECATED *)
_export "symbol" [cdecl | stdcall] : cfTy; ==> cfTy -> unit (* DEPRECATED *)
It doesn't seem like it would be hard for people to fix these in their
code.