Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] newbie problem with splitting code into files
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] newbie problem with splitting code into files
> i want to split code like for example the following into
> several files:

The following seems to do what you want:

----------- file test.mli -------------

class type test_type = object
        val mutable x:int
        method get_x:int
end
 
class test : test_type

----------- file test.ml --------------

class type test_type = object
        val mutable x:int
        method get_x:int
end
 
class test : test_type = object
        val mutable x = 0
        method get_x = x
end

----------- file main.ml --------------

open Test
open Printf

let main() = 
        let t=new test in
        printf "X: %d\n" t#get_x;; 
 
let _ = main()

---------------------------------------

Hope this helps,

- Xavier Leroy

-------------------
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