Browse thread
[Caml-list] Unix.kill on Win32
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David Brown <caml-list@d...> |
| Subject: | Re: [Caml-list] static class member.... |
On Wed, Aug 06, 2003 at 03:45:23PM +0100, Richard Jones wrote: > On Wed, Aug 06, 2003 at 04:57:26PM +0400, Vovka wrote: > > Hi!!!! > > > > Could you help me please. I'm newbie in ocaml programming, i used to write > > programmes in C++ , so I've faced difficulties in introducing static > > class member(==a common member for all objects of the same class). Can i > > handle it in ocaml? Thanks a lot. > > This is one way to do it, there might be other easier ways: > > class foo = > let counter = ref 0 in But this counter will be unique for each new instance of the class. What they are really asking for is something like let counter = ref 0 class foo = ... counter ... There is only one counter, globally. Remember, Ocaml separates the namespace management (modules) from the class system. It is easy to hide "counter" with the module spec. Dave ------------------- 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