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 442D7BB9A for ; Tue, 8 Nov 2005 15:58:50 +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 jA8Ewn9n010992 for ; Tue, 8 Nov 2005 15:58:49 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA08484 for ; Tue, 8 Nov 2005 15:58:49 +0100 (MET) Received: from conn.mc.mpls.visi.com (conn.mc.mpls.visi.com [208.42.156.2]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jA8Ewm8F010988 for ; Tue, 8 Nov 2005 15:58:49 +0100 Received: from [192.168.42.2] (bhurt.dsl.visi.com [208.42.141.66]) by conn.mc.mpls.visi.com (Postfix) with ESMTP id 098DB83B1; Tue, 8 Nov 2005 08:58:48 -0600 (CST) Date: Tue, 8 Nov 2005 09:02:44 -0600 (CST) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Cc: caml-list Subject: Re: Ant: [Caml-list] The "Objective" part of Objective Caml In-Reply-To: Message-ID: References: <20051107214110.46596.qmail@web26805.mail.ukl.yahoo.com> <87acggxguw.fsf@mid.deneb.enyo.de> <1131414473.23991.37.camel@rosella> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-980374224-1131462164=:20621" X-Miltered: at nez-perce with ID 4370BD29.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4370BD28.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 allocating:01 ocaml:01 2005,:98 factory:98 factory:98 wrote:01 modules:01 readable:02 patterns:02 caml:02 objective:02 objective:02 unreadable: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 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-980374224-1131462164=:20621 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 8 Nov 2005, Daniel B=FCnzli wrote: > > Le 8 nov. 05 =E0 03:15, Brian Hurt a =E9crit : > >> So patterns like singletons are hard to implement with Ocaml objects. > > Don't you have immediate objects [1] to do singletons ? No- because immediate objects still allocate a new object every time they= =20 are evaluated. I suppose you could do: let factory =3D let myobject =3D new myclass in fun () -> myobject ;; and do a factory method, but there is no way (that I know of) to prevent=20 someone else from doing: let myotherobject =3D new myclass and allocating a different object of the same class. No, the proper way to do singletons in Ocaml is with modules, not objects. Brian --8323328-980374224-1131462164=:20621--