caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] prevent more than one object
@ 2003-07-02 16:14 Mirko Aigner
  2003-07-02 16:43 ` Nick Name
  2003-07-03 11:20 ` John Max Skaller
  0 siblings, 2 replies; 4+ messages in thread
From: Mirko Aigner @ 2003-07-02 16:14 UTC (permalink / raw)
  To: caml-list

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 <- newdata;
   end;;

let instance = new singleton 0

let get_instance = instance

(*singleton.mli*)
class singleton :
   int ->
   object
     method get_data : int
     method set_data : int -> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-07-03 11:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-02 16:14 [Caml-list] prevent more than one object Mirko Aigner
2003-07-02 16:43 ` Nick Name
2003-07-03 11:20 ` John Max Skaller
2003-07-03 11:36   ` Mirko Aigner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).