From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id NAA28842 for caml-redistribution; Wed, 9 Oct 1996 13:41:33 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id MAA26254 for ; Wed, 9 Oct 1996 12:44:46 +0200 Received: from psyche.inria.fr (psyche.inria.fr [138.96.48.36]) by nez-perce.inria.fr (8.7.6/8.7.1) with ESMTP id MAA17784 for ; Wed, 9 Oct 1996 12:44:44 +0200 (MET DST) Received: by psyche.inria.fr (8.7.6/8.6.12) id MAA16986; Wed, 9 Oct 1996 12:44:44 +0200 (MET DST) Message-Id: <199610091044.MAA16986@psyche.inria.fr> X-Mailer: exmh version 1.6.7 5/3/96 To: caml-list@inria.fr Subject: Re: Constructeurs en O'Caml In-reply-to: Your message of "Wed, 09 Oct 1996 12:26:31 +0200." <199610091026.MAA11690@arthur.u-strasbg.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 09 Oct 1996 12:44:44 +0200 From: Vyskocil Vladimir Sender: weis > 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 > Yes, but such contructor can't call a object method because self is bind only at execution ie I can't do the following : class my_class name as self = (* MEMBERS *) val n = (* begin constructor *) self#init; ...; (* end constructor *) name (* METHODS *) method init = ... end -- Vyskocil Vladimir vvyskoci@sophia.inria.fr http://www.inria.fr/safir/SAFIR/Vladimir.html