Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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


Bug reports:  FAQ:
To unsubscribe, mail  Archives: