<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/07/49d3704bd9b76044d06a619f87144574"
  from="Mirko Aigner &lt;Mirko.Aigner@a...&gt;"
  author="Mirko Aigner"
  date="2003-07-02T16:14:24"
  subject="[Caml-list] prevent more than one object"
  prev="2003/07/bd53a57beae50542d0de9e1d4ee8ce61"
  next="2003/07/1289d7b595f1d629c162939d33309862"
  next-in-thread="2003/07/1289d7b595f1d629c162939d33309862"
  prev-thread="2003/07/d3684049ef97610c271443c5f8c1c003"
  next-thread="2003/07/9d5c44985ef4846fa1879e4f91dc551f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] prevent more than one object">
<msg 
  url="2003/07/49d3704bd9b76044d06a619f87144574"
  from="Mirko Aigner &lt;Mirko.Aigner@a...&gt;"
  author="Mirko Aigner"
  date="2003-07-02T16:14:24"
  subject="[Caml-list] prevent more than one object">
<msg 
  url="2003/07/1289d7b595f1d629c162939d33309862"
  from="Nick Name &lt;nick.name@i...&gt;"
  author="Nick Name"
  date="2003-07-02T16:42:04"
  subject="Re: [Caml-list] prevent more than one object">
</msg>
<msg 
  url="2003/07/e6b497b6561e6b659094f56674cbd2d4"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2003-07-03T11:20:34"
  subject="Re: [Caml-list] prevent more than one object">
<msg 
  url="2003/07/1a00e490e8337df3f522867c8a55be6e"
  from="Mirko Aigner &lt;Mirko.Aigner@a...&gt;"
  author="Mirko Aigner"
  date="2003-07-03T11:36:21"
  subject="Re: [Caml-list] prevent more than one object">
</msg>
</msg>
</msg>
</thread>

<contents>
Hi !

I'm looking for a way to prevent that from a class more than one object 
is builded. Therefor I wrote this little files

(*singleton.ml*)
class singleton x =
   object
     val mutable data : int = x;
     method get_data = data;
     method set_data newdata = data &lt;- newdata;
   end;;

let instance = new singleton 0

let get_instance = instance

(*singleton.mli*)
class singleton :
   int -&gt;
   object
     method get_data : int
     method set_data : int -&gt; unit
   end;;

val get_instance : singleton

The problem is the class is still public and instances can be build, any 
way to prevent this ?!

thx for helping
Mirko Aigner

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

</contents>

</message>

