[MLton] cvs commit: _{ex,im}port and :>

sweeks@mlton.org sweeks@mlton.org
Sun, 30 Nov 2003 15:39:10 -0800


sweeks      03/11/30 15:39:10

  Modified:    mlton/elaborate elaborate-core.fun
  Log:
  MAIL _{ex,im}port and :>
  
  _{ex,im}port now look inside opaque types to determine whether or not
  a type can be used by the FFI.  So, for example, the following program
  is accepted.
  
  structure S:> sig type t end =
     struct type t = int end
  val _ = _import "f": S.t -> S.t;
  
  The decision was made to go this way, despite the seeming
  contradiction with the opacity of :>, because there is no way to
  specify in a signature that a type is "ffi-able".  So, it seems better
  to allow the programmer the power to expose the property.  The
  programmer can disallow it by wrapping a type in a datatype.

Revision  Changes    Path
1.52      +2 -0      mlton/mlton/elaborate/elaborate-core.fun

Index: elaborate-core.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/elaborate/elaborate-core.fun,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- elaborate-core.fun	22 Nov 2003 23:18:48 -0000	1.51
+++ elaborate-core.fun	30 Nov 2003 23:39:09 -0000	1.52
@@ -671,6 +671,7 @@
 	    ty: Type.t,
 	    region: Region.t}: Prim.t =
    let
+      val ty = Type.expandOpaque (ty, Type.Always)
       fun error l = Control.error (region, l, Layout.empty)
       fun invalidAttributes () =
 	 error (seq [str "invalid attributes for import: ",
@@ -723,6 +724,7 @@
 
 fun export {attributes, name: string, region: Region.t, ty: Type.t}: Aexp.t =
    let
+      val ty = Type.expandOpaque (ty, Type.Always)
       fun error l = Control.error (region, l, Layout.empty)
       fun invalidAttributes () =
 	 error (seq [str "invalid attributes for export: ",