caml-list - the Caml user's mailing list
 help / Atom feed
* 
@ 2004-08-23 20:27 briand
  2004-08-23 20:36 ` [Caml-list] Re : [path directives] Jean-Baptiste Rouquier
  2004-08-24  9:09 ` [Caml-list] Damien Doligez
  0 siblings, 2 replies; 6+ messages in thread
From: briand @ 2004-08-23 20:27 UTC (permalink / raw)
  To: caml-list


This is a really weird user experience :


~/src/ocaml/math $ ocaml
        Objective Caml version 3.08.0

# #load "const.cmo";;
# Const.pi
  ;;
- : float = 3.14159265358979312
# 

Great, so that works as per the manual...
So then I change into another directory and load the EXACT SAME file.


~/src/ocaml/math $ cd ..
~/src/ocaml $ cd pll
~/src/ocaml/pll $ ocaml
        Objective Caml version 3.08.0

# #load "../math/const.cmo";;
# Const.pi;;
Unbound value Const.pi

Huh ??

Brian


-------------------
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] 6+ messages in thread

* [Caml-list] Re : [path directives]
  2004-08-23 20:27 briand
@ 2004-08-23 20:36 ` Jean-Baptiste Rouquier
  2004-08-24  1:41   ` briand
  2004-08-24  9:09 ` [Caml-list] Damien Doligez
  1 sibling, 1 reply; 6+ messages in thread
From: Jean-Baptiste Rouquier @ 2004-08-23 20:36 UTC (permalink / raw)
  To: caml-list

It bites me quite often. Add a
#directory "/home/login/src/ocaml/pll";;
at the beginning of your session, to let ocaml find the file const.cmi.

Jean-Baptiste Rouquier.

>~/src/ocaml/math $ ocaml
>        Objective Caml version 3.08.0
>
># #load "const.cmo";;
># Const.pi
>  ;;
>- : float = 3.14159265358979312
>So then I change into another directory and load the EXACT SAME file.
>
>
>~/src/ocaml/math $ cd ../pll
>~/src/ocaml/pll $ ocaml
>        Objective Caml version 3.08.0
>
># #load "../math/const.cmo";;
># Const.pi;;
>Unbound value Const.pi

-------------------
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] 6+ messages in thread

* [Caml-list] Re : [path directives]
  2004-08-23 20:36 ` [Caml-list] Re : [path directives] Jean-Baptiste Rouquier
@ 2004-08-24  1:41   ` briand
  2004-08-24  1:54     ` Jacques GARRIGUE
  0 siblings, 1 reply; 6+ messages in thread
From: briand @ 2004-08-24  1:41 UTC (permalink / raw)
  To: Jean-Baptiste Rouquier; +Cc: caml-list



Thank you very much for the solution.

Why doesn't the load fail or give some indication of a problem ?

Why doesn't caml know to look in the same directory which const.cmo
came from ?

I think I'll take a look through the sources and try and understand
why this isn't more user friendly.

Brian

>>>>> "Jean-Baptiste" == Jean-Baptiste Rouquier <jrouquiethearchiveshouldhaveafewantispamtricks@ens-lyon.fr> writes:

  Jean-Baptiste> It bites me quite often. Add a #directory
  Jean-Baptiste> "/home/login/src/ocaml/pll";; at the beginning of
  Jean-Baptiste> your session, to let ocaml find the file const.cmi.

  Jean-Baptiste> Jean-Baptiste Rouquier.

  >> ~/src/ocaml/math $ ocaml Objective Caml version 3.08.0
  >> 
  >> # #load "const.cmo";; # Const.pi
  >> ;;
  >> - : float = 3.14159265358979312 So then I change into another
  >> directory and load the EXACT SAME file.
  >> 
  >> 
  >> ~/src/ocaml/math $ cd ../pll ~/src/ocaml/pll $ ocaml Objective
  >> Caml version 3.08.0
  >> 
  >> # #load "../math/const.cmo";; # Const.pi;; Unbound value Const.pi

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

-------------------
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] 6+ messages in thread

* Re: [Caml-list] Re : [path directives]
  2004-08-24  1:41   ` briand
@ 2004-08-24  1:54     ` Jacques GARRIGUE
  2004-08-25 18:54       ` briand
  0 siblings, 1 reply; 6+ messages in thread
From: Jacques GARRIGUE @ 2004-08-24  1:54 UTC (permalink / raw)
  To: briand; +Cc: jrouquiethearchiveshouldhaveafewantispamtricks, caml-list

From: briand@aracnet.com

> Why doesn't the load fail or give some indication of a problem ?
> 
> Why doesn't caml know to look in the same directory which const.cmo
> came from ?
> 
> I think I'll take a look through the sources and try and understand
> why this isn't more user friendly.

The basic reason is that there are two files to read: const.cmo and
const.cmi, and they are loaded by two independent mechanisms.
const.cmo must be loaded explicitly by a #load command, but const.cmi
is searched automatically in the path when a Const.xxx identifier is
used.
The independence of the two mechanisms may be confusing, but you may
understand it better if you think of loading a .cma file: in that
case, you really don't know where the corresponding .cmi should be.

Jacques Garrigue

-------------------
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] 6+ messages in thread

* [Caml-list] Re: 
  2004-08-23 20:27 briand
  2004-08-23 20:36 ` [Caml-list] Re : [path directives] Jean-Baptiste Rouquier
@ 2004-08-24  9:09 ` Damien Doligez
  1 sibling, 0 replies; 6+ messages in thread
From: Damien Doligez @ 2004-08-24  9:09 UTC (permalink / raw)
  To: briand; +Cc: caml-list

On Aug 23, 2004, at 22:27, briand@aracnet.com wrote:

> ~/src/ocaml/math $ ocaml
>         Objective Caml version 3.08.0
>
> # #load "const.cmo";;
> # Const.pi
>   ;;
> - : float = 3.14159265358979312
> #
>
>
> ~/src/ocaml/math $ cd ..
> ~/src/ocaml $ cd pll
> ~/src/ocaml/pll $ ocaml
>         Objective Caml version 3.08.0
>
> # #load "../math/const.cmo";;
> # Const.pi;;
> Unbound value Const.pi
>
> Huh ??

What is the type of Const.pi?  In order to answer this question, you 
have
to know the interface of module Const.  This interface lives in 
const.mli,
which is compiled to const.cmi.  It is automatically looked up in the
current directory, but not in ../math (unless you use option -I).

In other words, a module is composed of two things: its interface and
its implementation.  The interface is all you need to know at compile
time, while the implementation is all you need at execution time.  But
the toplevel does both compilation and execution, so it needs both.
The #load directive only provides the implementation.  You should also
add "../math" to the interface search path with the #directory 
directive:

# #load "../math/const.cmo";;
# #directory "../math";;
# Const.pi;;

-- Damien

-------------------
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] 6+ messages in thread

* Re: [Caml-list] Re : [path directives]
  2004-08-24  1:54     ` Jacques GARRIGUE
@ 2004-08-25 18:54       ` briand
  0 siblings, 0 replies; 6+ messages in thread
From: briand @ 2004-08-25 18:54 UTC (permalink / raw)
  To: Jacques GARRIGUE; +Cc: jrouquiethearchiveshouldhaveafewantispamtricks, caml-list

>>>>> "Jacques" == Jacques GARRIGUE <garrigue@kurims.kyoto-u.ac.jp> writes:

  Jacques> The basic reason is that there are two files to read:
  Jacques> const.cmo and const.cmi, and they are loaded by two
  Jacques> independent mechanisms.  const.cmo must be loaded
  Jacques> explicitly by a #load command, but const.cmi is searched
  Jacques> automatically in the path when a Const.xxx identifier is
  Jacques> used.  The independence of the two mechanisms may be
  Jacques> confusing, but you may understand it better if you think of
  Jacques> loading a .cma file: in that case, you really don't know
  Jacques> where the corresponding .cmi should be.

I understand the separation of implementation vs interface, however it
seems that a reasonable default it to use the path of the cma file to
find the cmi before giving up.

However if the mechanisms are _completely_ separate then I can see
where that would be a problem, and I believe that is what your are
saying (?)

Thanks

Brian

-------------------
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] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-23 20:27 briand
2004-08-23 20:36 ` [Caml-list] Re : [path directives] Jean-Baptiste Rouquier
2004-08-24  1:41   ` briand
2004-08-24  1:54     ` Jacques GARRIGUE
2004-08-25 18:54       ` briand
2004-08-24  9:09 ` [Caml-list] Damien Doligez

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox