I am trying to replace (a small part) of my program while it is running using the Dynlink module. I have tried to replicate this example:
http://zderadicka.eu/plugins-in-ocaml-with-dynlink-library/
In my code, I have a plugface library, that is available to both main and the plugin. So I set the refs from the plugin, and can then read it using get_plugin ()
in my main exec.
let p = ref None
let get_plugin () : int Seq.t =
match !p with
| Some s -> s
| None -> failwith "No plugin loaded"
plugin.ml
open Plugface
let () =
let _ = print_endline "version 3.21" in
p := Some (Seq.cycle (List.to_seq [200]))
This works the first time like I would expect .
However, when I edit my plugin.ml and then recompile it and try to load the “plugin.cmxs” for a second time in main.app. I don’t get an error, but also nothing really changes, it seems that it just running the old code again, instead of the new. Is this expected? Is it even possible what I try to do?
4 posts - 3 participants