I've been having trouble with this very simple thing, and I was wondering if anyone could
help me out:
I have three files:
(* burp.mli: *)
class type foo =
object
method bar : int
end
(* burp.ml *)
class foo (a : int) =
object
method bar =
a * a
end
(* run.ml *)
open Burp
let _ =
let b = new Burp.foo 2 in
Printf.printf "%dn" b#bar
My makefile essentially does 'ocamlc -c *.mli *.ml'. burp.mli and burp.ml compile without
any problem, but compilation of run.ml fails with:
File "run.ml", line 4, characters 10-22:
Unbound class Burp.foo
If I take the "main" program from run.ml and insert it instead in burp.ml, the whole thing
compiles and runs fine. I have read the sections on modules and
object-oriented programming in "Developing Applications with Objective Caml", and I have
also looked through the MLDonkey code base to get some clues on how to do
this, and I still can't make even this simple example work. I would be very appreciative of
any suggestions or pointers to relevant literature.
Thanks,
-M.D.
.