caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
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 14:12:52 +0200	[thread overview]
Message-ID: <199610091212.OAA12196@arthur.u-strasbg.fr> (raw)
In-Reply-To: <199610091044.MAA16986@psyche.inria.fr>


Vyskocil Vladimir writes:
 > 
 > [ ... see my previous message]
 > 
 > Yes, but such contructor can't call a object method because self is
 > bind only at execution ie I can't do the following :
 >
 > [ ... ]

Agreed, this is because you're not allowed to send messages to a partially
constructed object.

Solutions may be:

1) the 'val _ = ...' I suggested should be evaluated after all others
member initializations. [self] can then be safely bound inside the right part.

Pro: the 'val _' is like any other val, i.e it contains code evaluated
     at object creation time.

Cons: the 'val _' is the only member where self is bound.


2) as you suggested it, a constructor method can do the job
 (either named [init] or [my_class], the later would recall C++ ...).

Pro: self is bound in the 'method init = ...' as it is for all methods.

Cons: the 'init' method is called at object creation time, and you should not
     be allowed to call it directly.


3) Any other idea ?


But for sure, constructors are an usefull idiom !

-- Christian Boos




  reply	other threads:[~1996-10-09 16:19 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
1996-10-09 10:44   ` Vyskocil Vladimir
1996-10-09 12:12     ` Christian Boos [this message]
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=199610091212.OAA12196@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;
as well as URLs for NNTP newsgroup(s).