creating fresh objects of type 'self

From: Markus Mottl (
Date: Sat Apr 10 1999 - 00:56:44 MET DST

From: Markus Mottl <>
Message-Id: <>
Subject: creating fresh objects of type 'self
Date: Fri, 9 Apr 1999 23:56:44 +0100 (MET DST)


is there a convenient way of creating objects of type 'self in classes?

Cloning is easy, e.g:

  class foo = object
    method clone = {< >}

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

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,,

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:22 MET