From: Christian Boos <boos@arthur.u-strasbg.fr>
To: Vyskocil Vladimir <Vladimir.Vyskocil@sophia.inria.fr>
Cc: caml-list@inria.fr
Subject: Re: Constructeurs en O'Caml
Date: Wed, 9 Oct 1996 12:26:31 +0200 [thread overview]
Message-ID: <199610091026.MAA11690@arthur.u-strasbg.fr> (raw)
In-Reply-To: <199610090925.LAA15108@psyche.inria.fr>
Vyskocil Vladimir writes:
> Existe-t'il comme en C++ une fonction qui est appelee a la construction d'un
> objet (pas seulement pour initialiser des variables d'instances) ?
No, there's nothing such a "constructor" method, but a way to circumvent this
is to do the job as a side effect, when initializing the members. See the fol-
lowing sample code :
class my_class name =
(* MEMBERS *)
val n =
(* begin constructor *)
...;
(* end constructor *)
name
(* METHODS *)
...
end
I would suggest a clearer syntax for that, by the mean of anonymous members :
val _ = (* constructor code *)
Of course, these members will not be real fields in the object instances,
but just "fake" fields for the purpose of calling constructors. In that way,
you could have constructors for objects with no members.
-- Christian Boos
next prev parent reply other threads:[~1996-10-09 11:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-10-09 9:25 Vyskocil Vladimir
1996-10-09 10:26 ` Christian Boos [this message]
1996-10-09 10:44 ` Vyskocil Vladimir
1996-10-09 12:12 ` Christian Boos
1996-10-10 15:30 ` Jerome Vouillon
1996-10-23 13:01 ` Jacques GARRIGUE
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=199610091026.MAA11690@arthur.u-strasbg.fr \
--to=boos@arthur.u-strasbg.fr \
--cc=Vladimir.Vyskocil@sophia.inria.fr \
--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