* Toplevel - load cmo from given location
@ 2009-01-09 14:06 Dawid Toton
2009-01-09 14:39 ` [Caml-list] " Christophe TROESTLER
2009-01-09 17:33 ` Zheng Li
0 siblings, 2 replies; 5+ messages in thread
From: Dawid Toton @ 2009-01-09 14:06 UTC (permalink / raw)
To: caml-list
I've noticed stange behaviour:
The following works OK (using #directory directive):
#!/usr/bin/ocamlrun ocaml
#directory "/home/dt2/Calc1/CalcEngine/src/_build/extlib/"
#load "enum.cmo"
open Enum
But this version not (using the full path directly):
#!/usr/bin/ocamlrun ocaml
#load "/home/dt2/Calc1/CalcEngine/src/_build/extlib/enum.cmo"
open Enum
The problem is that it gives "Unbound module Enum" while no error about
loading the cmo&cmi is shown.
So:
* if it finds correctly the enum.cmi: why "open Enum" doesn't work?
* if the cmi is not found, why I see no message like "*Cannot find file
*/home/dt2/Calc1/CalcEngine/src/_build/extlib/enum.cmi*" - as chapter
9.4 of docs suggests? Does the toplevel check for the cmi in the same
location as cmo? *
(I tested this with the cmi file existing there as built by ocamlbuild)
Dawid
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Toplevel - load cmo from given location
2009-01-09 14:06 Toplevel - load cmo from given location Dawid Toton
@ 2009-01-09 14:39 ` Christophe TROESTLER
2009-01-09 15:08 ` Dawid Toton
2009-01-09 17:33 ` Zheng Li
1 sibling, 1 reply; 5+ messages in thread
From: Christophe TROESTLER @ 2009-01-09 14:39 UTC (permalink / raw)
To: OCaml Mailing List
On Fri, 09 Jan 2009 14:06:25 +0000, Dawid Toton wrote:
>
> I've noticed stange behaviour:
>
> The following works OK (using #directory directive):
>
> #!/usr/bin/ocamlrun ocaml
> #directory "/home/dt2/Calc1/CalcEngine/src/_build/extlib/"
> #load "enum.cmo"
> open Enum
>
> But this version not (using the full path directly):
>
> #!/usr/bin/ocamlrun ocaml
> #load "/home/dt2/Calc1/CalcEngine/src/_build/extlib/enum.cmo"
> open Enum
>
> The problem is that it gives "Unbound module Enum" while no error about loading the cmo&cmi is shown.
The #directory instruction is needed to find the .cmi.
My 0.02€,
ChriS
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Toplevel - load cmo from given location
2009-01-09 14:39 ` [Caml-list] " Christophe TROESTLER
@ 2009-01-09 15:08 ` Dawid Toton
2009-01-09 21:39 ` Richard Jones
0 siblings, 1 reply; 5+ messages in thread
From: Dawid Toton @ 2009-01-09 15:08 UTC (permalink / raw)
To: caml-list
>> The problem is that it gives "Unbound module Enum" while no error about loading the cmo&cmi is shown.
>
> The #directory instruction is needed to find the .cmi.
I see, so there are 2 problems:
* why the failure to load cmi is silent in this case?
* why the toplevel fails to check for cmi where the cmo is located? This
looks as incorrect behaviour (the reference manual doesn't mention any
exceptional rules for the #load directive).
Dawid
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Toplevel - load cmo from given location
2009-01-09 14:06 Toplevel - load cmo from given location Dawid Toton
2009-01-09 14:39 ` [Caml-list] " Christophe TROESTLER
@ 2009-01-09 17:33 ` Zheng Li
1 sibling, 0 replies; 5+ messages in thread
From: Zheng Li @ 2009-01-09 17:33 UTC (permalink / raw)
To: Dawid Toton; +Cc: caml-list
Hi,
On 1/9/2009 3:06 PM, Dawid Toton wrote:
> But this version not (using the full path directly):
>
> #!/usr/bin/ocamlrun ocaml
> #load "/home/dt2/Calc1/CalcEngine/src/_build/extlib/enum.cmo"
> open Enum
>
> The problem is that it gives "Unbound module Enum" while no error about
> loading the cmo&cmi is shown.
It's because the toplevel doesn't have the "/home/dt2/..." in its paths,
so it doesn't know where the enum.cmi is.
> So:
> * if it finds correctly the enum.cmi: why "open Enum" doesn't work?
No, it doesn't find the enum.cmi
> * if the cmi is not found, why I see no message like "*Cannot find file
> */home/dt2/Calc1/CalcEngine/src/_build/extlib/enum.cmi*" - as chapter
The enum.cmi was there, it was because the toplevel didn't know about
this path. So it had the same effect as accessing a non-existed module
or a module existed but not in the known paths (e.g. open NoSuchModule).
> 9.4 of docs suggests? Does the toplevel check for the cmi in the same
> location as cmo? *
No. Basically, cmi and cmo are two different things. You using one
doesn't mean you'll use the other.
Using the "directory" directive or launching toplevel with "-I"
parameters can add extra paths to toplevel (for accessing both cmi and cmo).
HTH.
--
Zheng
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] Toplevel - load cmo from given location
2009-01-09 15:08 ` Dawid Toton
@ 2009-01-09 21:39 ` Richard Jones
0 siblings, 0 replies; 5+ messages in thread
From: Richard Jones @ 2009-01-09 21:39 UTC (permalink / raw)
To: Dawid Toton; +Cc: caml-list
On Fri, Jan 09, 2009 at 03:08:18PM +0000, Dawid Toton wrote:
>
> >>The problem is that it gives "Unbound module Enum" while no error about
> >>loading the cmo&cmi is shown.
> >
> >The #directory instruction is needed to find the .cmi.
>
> I see, so there are 2 problems:
> * why the failure to load cmi is silent in this case?
> * why the toplevel fails to check for cmi where the cmo is located? This
> looks as incorrect behaviour (the reference manual doesn't mention any
> exceptional rules for the #load directive).
As you say this is kind of a bug. You cannot solve it by assuming
some sort of one-to-one relationship between .cmi files and .cmo files
though. You can have .cmi without .cmo, or .cmo without .cmi, or lots
of .cmi and a .cma, and probably other combinations.
Couple of practical points though: (1) Use ocamlfind in the toplevel
to solve all these problems:
# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #require "netstring";;
/usr/lib64/ocaml/pcre: added to search path
/usr/lib64/ocaml/pcre/pcre.cma: loaded
/usr/lib64/ocaml/unix.cma: loaded
/usr/lib64/ocaml/netsys: added to search path
/usr/lib64/ocaml/netsys/netsys.cma: loaded
/usr/lib64/ocaml/netstring: added to search path
/usr/lib64/ocaml/netstring/netstring.cma: loaded
/usr/lib64/ocaml/netstring/netstring_top.cmo: loaded
/usr/lib64/ocaml/netstring/netaccel.cma: loaded
/usr/lib64/ocaml/netstring/netaccel_link.cmo: loaded
(2) Bugs should go in the bug tracker here:
http://caml.inria.fr/mantis/
Rich.
--
Richard Jones
Red Hat
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-09 21:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-09 14:06 Toplevel - load cmo from given location Dawid Toton
2009-01-09 14:39 ` [Caml-list] " Christophe TROESTLER
2009-01-09 15:08 ` Dawid Toton
2009-01-09 21:39 ` Richard Jones
2009-01-09 17:33 ` Zheng Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox