Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] class variables?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Warp <warplayer@f...>
Subject: Re: [Caml-list] class variables?
> Hi,
>
> I'm considering using ocaml for a project I'm planning.  I plan to use the
> object-oriented features of ocaml extensively.  I was wondering: is there
> any way to get immutable class fields that are shared by all members of
the
> class?  I was thinking of a list of strings, and I don't want to have to
> have the list duplicated for every instance of the class.

Maybe you can try using 'ref'

let strlist = ref []
...
strlist := ["a";"b";"c"] (* change inner value *)

then you can read what's "inside" strlist using !strlist

Warp

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr