Joel Stanley wrote:
I've seen the ForeignTest.{c,sml} example of passing callbacks to C functions using Poly/ML's C FFI (ie, via things like the FUNCTION2 conversion). Is there a way to do this without calling C from Poly/ML?
Asked another way, is there a straightforward way to start the Poly/ML runtime from a C main() function, and then call Poly/ML functions (perhaps only those which have been registered via some kind of callback registration mechanism) from C?
This isn't possible with the code as it stands. I'm not sure what would be required to make it work. The fundamental issue is the where the threads that are executing in the ML code were created. The only way I can see of doing this would be to use pthreads to create an ML thread that calls a C function to wait for callbacks.
David