From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA29521 for caml-redistribution; Tue, 6 Apr 1999 08:52:05 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA07913 for ; Sat, 3 Apr 1999 12:38:04 +0200 (MET DST) Received: from irritatie.cs.kun.nl (irritatie.cs.kun.nl [131.174.33.129]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id MAA26160 for ; Sat, 3 Apr 1999 12:38:02 +0200 (MET DST) Received: (from tews@localhost) by irritatie.cs.kun.nl (8.8.7/8.8.7) id MAA07271; Sat, 3 Apr 1999 12:40:56 +0200 Date: Sat, 3 Apr 1999 12:40:56 +0200 Message-Id: <199904031040.MAA07271@irritatie.cs.kun.nl> From: Hendrik Tews MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: caml-list@inria.fr Subject: Re: initialization of instance variables In-Reply-To: <14083.34604.727325.126299@hadar.cse.Buffalo.EDU> References: <14077.2636.294799.938058@hadar.cse.Buffalo.EDU> <19990401151014.56489@pauillac.inria.fr> <14083.34604.727325.126299@hadar.cse.Buffalo.EDU> X-Mailer: VM 6.22 under 19.15 XEmacs Lucid Sender: weis John Whitley writes: While the let-bound version works, it seems to obfuscate the intent, which was to have an instance variable called 'x'. It also means that a subclass inheriting foo' cannot reuse or redefine x. I have two remarks about that: 1. IMO the intent of your example is that a complicated function is computed just before object creation. I think this is best captured by the let construction. Alternatively you could use initializers and exploit late binding in the computation of the complicated function. 2. You can still have an instance variable x: (* make initial computation _very_ explicit *) class foo' input = let x_init = complicated_function input in let y_init = another function x_init in object val x = x_init val y = y_init (* those imaginary methods again... *) end Bye, Hendrik