caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] dynlink and toplevel
@ 2004-06-03 15:19 James Scott
  0 siblings, 0 replies; only message in thread
From: James Scott @ 2004-06-03 15:19 UTC (permalink / raw)
  To: Caml List


Hi All, 


we're doing some work where it's useful to use Dynlink in the
toplevel, but we've run into a snag: if the Dynlink-loaded module
refers to modules loaded by '#load' or on the command line, they're
not resolved. But if they're put into a 'custom' toplevel they are, e.g.

$ cat Loader.ml 
let dynload_helper_ref = ref (None: int option)

let doit fname =
  let _ = Dynlink.init () in
  let _ = Dynlink.loadfile fname in
  !dynload_helper_ref


$ cat Loadee.ml 
Loader.dynload_helper_ref := Some 1

$ cat Test.ml
let _ = Loader.doit "Loadee.cmo" ;;

$ ocamlc -c Loadee.ml
$ ocamlc -a -o llib.cma Loader.ml 
$ ocaml dynlink.cma llib.cma Test.ml
Exception:
Dynlink.Error
 (Dynlink.Linking_error ("Loadee.cmo", Dynlink.Undefined_global "Loader")).


But this works:

$ ocamlmktop dynlink.cma llib.cma
$ ./a.out < Test.ml
        Objective Caml version 3.07+2

# - : int option = Some 1


This was a bit of a surprise as I was expecting the two load semantics
to be identical... but is there any way round it?

James 

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-06-03 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-03 15:19 [Caml-list] dynlink and toplevel James Scott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).