[MLton-devel] Callbacks

Matthew Fluet fluet@cs.cornell.edu
Tue, 20 May 2003 08:54:29 -0400 (EDT)


> It all makes sense.  My one minor complaint is that the functions are
> curried (I understand that they have to be due to the printf-style
> stuff).  My major complaint is that there is too much work and room
> for error on the C side.  I would prefer if the exported function
> appeared to be a normal C function.

I guess; but one might well argue that there is just as much room for
error on the ML side for importing C functions.  When I write
  _ffi "foo" : unit -> unit;
nothing complains when foo is really:
  int foo(int x) { return x; }

> MLton also builds the appropriate C routine for each export, which is
> easy to do from the type.  Our example would generate
>
> 	int A (int x1, int x1) {
> 	        MLton_FFI_setI (0, 13);
> 	        MLton_FFI_setI (1, x1);
> 	        MLton_FFI_setI (2, x2);
> 	        MLton_callFromC ();
> 	        return MLton_FFI_getI (0);
> 	}

This presumably get's dumped into some auxilary .c file that is compiled
and linked into the .o for the SML?





-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel