Version française
Home     About     Download     Resources     Contact us    
Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien Doligez <damien.doligez@i...>
Subject: [Caml-list] Re:
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