Class variables in O'Caml???

Thorsten Ohl (ohl@crunch.ikp.physik.th-darmstadt.de)
Fri, 10 May 1996 12:46:02 +0200

Date: Fri, 10 May 1996 12:46:02 +0200
Message-Id: <9605101046.AA12307@crunch>
From: Thorsten Ohl <ohl@crunch.ikp.physik.th-darmstadt.de>
To: caml-list@pauillac.inria.fr
Subject: Class variables in O'Caml???

I have played a little bit with O'Caml yesterday and found that the
new features very conveniently formalize what I had been doing with
mutable records already. Good job!

I have one question however: it seems that all variables in a class
are instance variables. Have I overlooked something in the
documentation or can somebody explain to me why class variables
(i.e. variables that are shared mong all instances of a class) are a
bad idea?

The typical application is a class of non-uniform random number
generators, where the distribution to be generated would be an
instance variable, while the state of the underlying uniform
generator should be a class variable. This way, differrent instances
will generate different distributions, but draw from the _same_ source
of random numbers.

It is possible to emulate this with references, of course. But it
would be somewhat unnatural ...

Cheers,
-Thorsten