Hi.
It would be great if it were possible to use Poly/ML from other programming languages. There would be a polyml.so or polyml.dll file, that could be linked with, for example, the following C program:
#include "polyml.h"
main() { Poly_LoadDatabase("mydb.pmd"); int result = Poly_InvokeFunction_Int_Int("add_one", 5); printf("%d plus one is %d\n", 5, result); }
It would of course be better still if there could be a Poly/ML COM component or Poly/ML .NET component (unmanaged and non-verifiable, of course).
The problem with these scenarios is that Poly/ML would have to live together with other modules in the same process. This probably causes multithreading issues and address space issues.
Poly/ML uses memory mapping to load the database. It uses fixed addresses for this. What if the address range is being used by other modules?
Poly/ML uses certain operating system functionality to implement multithreading. Could this interfere with other modules?
We have a design space here: one extreme is Poly/ML, which is very efficient, but has rather poor interoperability. The other extreme is SML.NET (see www.research.microsoft.com) (I'm talking about the concept, since it has not (yet?) been released): this would provide great interoperability, but most probably at the expense of efficiency in time and space.
Of course, Poly/ML is the greatest programming language ever and all other languages are superfluous :-), but we cannot avoid the fact that some people use other languages, and, as a result, useful libraries get written in other languages. My problem is that I want to combine the Isabelle theorem proving system (isabelle.in.tum.de), written in SML, with the .NET Framework's user interface components.
As an approximation to the DLL approach I discussed above, I'm looking into writing some simple remote procedure call code to connect the Poly/ML process and the .NET process. That way, Poly/ML would be a kind of "server" accepting remote procedure calls through a socket. (See also my previous mail.)
Is it possible to run Poly/ML on Windows without the user interface? This would allow me to invisibly launch Poly/ML from the .NET program, with a database that contains an "onEntry" function that listens on a TCP port and accepts remote procedure calls.
Any thoughts on this?
It would be great if it were possible to use Poly/ML from other programming languages. There would be a polyml.so or polyml.dll file, that could be linked with, for example, the following C program: ...
You might look at the model we have for PLT Scheme, where the language is made available as a static library for linking, and under Windows, as a COM component.
See http://www.plt-scheme.org/ for more information.
-- Paul
You can do much of this with the current version. If you use CreateProcess to run Poly/ML as a process and provide standard input and standard output streams it will use those rather than create a GUI interface. This is the way MLShell works. You can even use Windows.execute to run a separate version of Poly/ML within Poly/ML itself.
val (inp, outp) = let open Windows val p = execute("C:\Program Files\Poly ML\PolyML.exe", ""C:\Program Files\Poly ML\PolyML.exe" "C:\Program Files\Poly ML\ML_dbase.pmd"") in (textInstreamOf p, textOutstreamOf p) end; fun writeOutput() = (print(TextIO.input inp); writeOutput()); Process.fork writeOutput; TextIO.output(outp, "1+2;\n"); TextIO.output(outp, "OS.Process.exit OS.Process.success;\n");
Note this will only work if you start running Poly/ML with a different database or if the database has been set to read-only. There is also a way to send an interrupt (control-C) to the process using DDE. If you want more information send me an email.
Running Poly/ML within the same address space is much more of a problem. As you point out the database is always mapped at the same address. This is to avoid having to relocate it whenever it is loaded. It's difficult to see how to get round this problem without big changes to the run-time system.
David.
On Friday, June 28, 2002, at 10:59 , Bart Jacobs wrote:
It would be great if it were possible to use Poly/ML from other programming languages. The problem with these scenarios is that Poly/ML would have to live together with other modules in the same process. This probably causes multithreading issues and address space issues.
As an approximation to the DLL approach I discussed above, I'm looking into writing some simple remote procedure call code to connect the Poly/ML process and the .NET process. That way, Poly/ML would be a kind of "server" accepting remote procedure calls through a socket. (See also my previous mail.)
Is it possible to run Poly/ML on Windows without the user interface? This would allow me to invisibly launch Poly/ML from the .NET program, with a database that contains an "onEntry" function that listens on a TCP port and accepts remote procedure calls.