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 IAA00707 for caml-redistribution; Mon, 12 Apr 1999 08:43:14 +0200 (MET DST) 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 XAA06610 for ; Fri, 9 Apr 1999 23:56:46 +0200 (MET DST) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id XAA29748 for ; Fri, 9 Apr 1999 23:56:45 +0200 (MET DST) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id XAA27233 for caml-list@inria.fr; Fri, 9 Apr 1999 23:56:45 +0200 (MET DST) From: Markus Mottl Message-Id: <199904092156.XAA27233@miss.wu-wien.ac.at> Subject: creating fresh objects of type 'self To: caml-list@inria.fr (OCAML) Date: Fri, 9 Apr 1999 23:56:44 +0100 (MET DST) X-Mailer: ELM [version 2.4 PL21] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: weis Hello, 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. But I wonder, how I can do something similar to get a "fresh" object. 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. Am I overseeing an obvious short solution? 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). Best regards, Markus Mottl -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl