From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA03028 for caml-redistribution; Mon, 12 Apr 1999 19:32:15 +0200 (MET DST) 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 LAA02706 for ; Mon, 12 Apr 1999 11:28:36 +0200 (MET DST) Received: from morgon.inria.fr (morgon.inria.fr [128.93.8.33]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id LAA29388; Mon, 12 Apr 1999 11:28:34 +0200 (MET DST) Received: (from remy@localhost) by morgon.inria.fr (8.8.7/8.8.7) id KAA02487; Mon, 12 Apr 1999 10:33:30 +0200 Message-ID: <19990412103328.05240@morgon.inria.fr> Date: Mon, 12 Apr 1999 10:33:28 +0200 From: Didier Remy To: Markus Mottl Cc: OCAML Subject: Re: creating fresh objects of type 'self Reply-To: Didier.Remy@inria.fr References: <199904092156.XAA27233@miss.wu-wien.ac.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.85e In-Reply-To: <199904092156.XAA27233@miss.wu-wien.ac.at>; from Markus Mottl on Fri, Apr 09, 1999 at 11:56:44PM +0100 Organization: INRIA, BP 105, F-78153 Le Chesnay Cedex Phone: (33) 1 3963 5317 -- Sec: (33) 1 3963 5570 -- Fax: (33) 1 3963 5684 Web: http://cristal.inria.fr/~remy Sender: weis > is there a convenient way of creating objects of type 'self in classes? > > Cloning is easy, e.g: > > class foo = object > method clone = {< >} > end > > which yields an object not necessarily of type "foo" but possibly of > a subclass. Yes. > But I wonder, how I can do something similar to get a "fresh" object. The method clone already gives you a fresh copy of the original object. So why aren't you happy with the method clone? > I would like to be able to have something like: > > class foo = object (_ : 'self) > method create = new 'self > end > > The only possibility I know to get the intended result is rather > inconvenient: I do as in "clone", but reinitialize all member data with > their initial data. This is not only error-prone, but possibly quite a > lot of work. I don't understand what you mean here. > The original idea is to have a parent *object* passing "self" to a child > *object* it has just created itself (note that I mean concrete objects, > not classes). I still don't undertand what you really want to do. Best regards, Didier.