From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 62DECBB9A for ; Tue, 8 Nov 2005 16:39:21 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jA8FdKcX015411 for ; Tue, 8 Nov 2005 16:39:21 +0100 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 QAA09563 for ; Tue, 8 Nov 2005 16:39:20 +0100 (MET) Received: from serv07.divms.uiowa.edu (serv07.divms.uiowa.edu [128.255.44.97]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jA8FdIax020382 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 8 Nov 2005 16:39:20 +0100 Received: from [128.255.45.190] (alexander@dpmlh065.divms.uiowa.edu [128.255.45.190]) by serv07.divms.uiowa.edu with id jA8FdHUw023601; Tue, 8 Nov 2005 09:39:17 -0600 Message-ID: <4370C6A6.4050109@uni-koblenz.de> Date: Tue, 08 Nov 2005 09:39:18 -0600 From: Alexander Fuchs User-Agent: Debian Thunderbird 1.0.2 (X11/20050602) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Brian Hurt Cc: caml-list Subject: Re: Ant: [Caml-list] The "Objective" part of Objective Caml References: <20051107214110.46596.qmail@web26805.mail.ukl.yahoo.com> <87acggxguw.fsf@mid.deneb.enyo.de> <1131414473.23991.37.camel@rosella> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.87.1/1166/Mon Nov 7 13:01:45 2005 on serv07.divms.uiowa.edu X-Virus-Status: Clean X-Miltered: at nez-perce with ID 4370C6A8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4370C6A6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 mli:01 foo:01 val:01 foo:01 val:01 endline:01 wrote:01 int:01 modules:01 caml:02 objective:02 objective:02 alexander:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Brian Hurt wrote: > No, the proper way to do singletons in Ocaml is with modules, not objects. I am not sure if you meant this by 'modules, not objects', but what about specifying only the class type interface of the singleton, but not the interface of the actual singleton class in the module interface: singleton.mli: --------------------------- (* class signature of the singleton *) class type foo = object method print_id: unit end (* the singleton *) val singleton: foo --------------------------- singleton.ml: --------------------------- (* copied from the interface *) class type foo = object method print_id: unit end (* the class of the singleton *) class bar id = object val id = id method print_id = print_endline (string_of_int id); end (* the singleton *) let singleton = new bar 0 --------------------------- Now you can access: Singleton.singleton;; but not create (as foo is just an interface): new Singleton.foo 1;; and not create (as bar is not exported to the interface): new Singleton.bar 2;;