Hello,

I need to find a way to put Ocaml program in memory so I could interact with the program
(call function, get result, find information about the variables, ...) without always reading the file.

That what append when we use the directive #use "file.ml";; in the interactive shell (the toplevel, when you type the command ocaml in a shell).

The instruction need to come from a Matlab function. So, I was thinking to create a process who run the ocaml command,
redirect his standard input in a named pipe, redirect his standard output in another named pipe, so I could send instructions and received responses.

But when I send the first instruction (ex : #use "file.ml";;\n), the ocaml process send back the response and stop.

____

file.ml :
let x = 10;;

____

                   "#use "file.ml";;\n"
Matlab --   /tmp/pipe_in  -->   ocaml

                   "val x : int = 10"
Matlab <-- /tmp/pipe_out --    ocaml
                                                  then ocaml stop...

___


So I would like to know if you think it's a good solution and if it is, do someone know how could I make it work ?

_

I've tried another solution. I use Unix.fork() and launch, in the son process, the ocaml command then
I send instructions from the father process to the son process with anonym pipe (Unix.pipe()).

But here I have trouble with blocking read, I send an instruction, read the answer but even if I've read all char of the answer, it's wait to read
more but there is no more to read...

I have tried to use Unix.set_nonblock() and catch EAGAIN, but then I don't get anything at all in the buffer given to Unix.read().

If someone could help, I would be grateful !
Lachat Paul