From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA22806; Wed, 2 Jul 2003 18:42:04 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA23219 for ; Wed, 2 Jul 2003 18:42:03 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from smtp0.cp.tin.it (vsmtp0.virgilio.it [212.216.176.136] (may be forged)) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h62Gg1f29491 for ; Wed, 2 Jul 2003 18:42:02 +0200 (MET DST) Received: from vsmtp6.tin.it (212.216.176.232) by smtp0.cp.tin.it (6.7.016) id 3EDFBB59008A831D; Wed, 2 Jul 2003 18:41:59 +0200 Received: from furia (80.181.248.251) by vsmtp6.tin.it (6.7.016) id 3EE06EE901F773D7; Wed, 2 Jul 2003 18:41:57 +0200 Received: from localhost ([127.0.0.1] helo=furia) by furia with smtp (Exim 3.35 #1 (Debian)) id 19XkiK-00015y-00; Wed, 02 Jul 2003 18:44:12 +0200 Date: Wed, 2 Jul 2003 18:43:56 +0200 From: Nick Name To: Mirko Aigner , caml-list@inria.fr Subject: Re: [Caml-list] prevent more than one object Message-Id: <20030702184356.15d48330.nick.name@inwind.it> In-Reply-To: <3F0304DF.1010300@alcatel.de> References: <3F0304DF.1010300@alcatel.de> X-Mailer: Sylpheed version 0.7.4claws (GTK+ 1.2.10; i386-debian-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; caml-list:01 alcatel:99 val:01 struct:01 dato:99 mio:99 forma:99 che:99 piu:99 sig:01 int:01 module:03 wrote:03 object:03 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 02 Jul 2003 18:14:23 +0200 Mirko Aigner wrote: > > The problem is the class is still public and instances can be build, > any way to prevent this ?! I would make the class private in the module and supply only access functions; if you need it to be a class you should expose only the class type, but there is Oo.copy so your value will never be granted unique. Try this module M : sig class type singleton = object method f : int end val x : singleton end = struct class singleton = object method f = 0 end let x = new singleton end You can't create a new singleton with "new" but still can do that with Oo.copy M.x. It is better to completely hide the type if you can, as in module M : sig type singleton val x : singleton end = struct ... Vincenzo -- Ho dato al mio dolore la forma di parole abusate che mi prometto di non pronunciare mai pił [CSI] ------------------- 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