From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: caml-list@inria.fr (OCAML)
Subject: creating fresh objects of type 'self
Date: Fri, 9 Apr 1999 23:56:44 +0100 (MET DST) [thread overview]
Message-ID: <199904092156.XAA27233@miss.wu-wien.ac.at> (raw)
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
next reply other threads:[~1999-04-12 6:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-09 22:56 Markus Mottl [this message]
1999-04-12 8:33 ` Didier Remy
1999-04-12 12:03 ` Markus Mottl
1999-04-12 10:39 ` Didier Remy
1999-04-12 13:10 ` Markus Mottl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199904092156.XAA27233@miss.wu-wien.ac.at \
--to=mottl@miss.wu-wien.ac.at \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox