From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA11248 for caml-redistribution; Thu, 1 Apr 1999 20:41:47 +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 RAA11419 for ; Thu, 1 Apr 1999 17:02:00 +0200 (MET DST) Received: from hadar.cse.Buffalo.EDU (hadar.cse.Buffalo.EDU [128.205.32.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id RAA07264 for ; Thu, 1 Apr 1999 17:01:56 +0200 (MET DST) Received: (from whitley@localhost) by hadar.cse.Buffalo.EDU (8.8.8/8.8.5) id KAA10186; Thu, 1 Apr 1999 10:01:56 -0500 (EST) From: John Whitley MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 1 Apr 1999 10:01:55 -0500 (EST) To: caml-list@inria.fr Subject: Re: initialization of instance variables In-Reply-To: <19990401151014.56489@pauillac.inria.fr> References: <14077.2636.294799.938058@hadar.cse.Buffalo.EDU> <19990401151014.56489@pauillac.inria.fr> X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs Lucid Message-ID: <14083.34604.727325.126299@hadar.cse.Buffalo.EDU> Sender: weis Jerome Vouillon writes: > It would actually be quite easy to allow the use of an instance > variable in the following instance variable definitions. The reason > it is not allowed for the moment is that I think it may be a bit > confusing. [discussion elided] Ah, indeed! That hadn't occured to me offhand, probably as the code that elicited this question uses immutable instance variables. In my code, the alternative of using let bindings seemed counter-intuitive: (* prohibited form *) class foo input = object val x = complicated_function input val y = another_function x (* imagine some methods... *) end (* a working, let-bound form *) class foo' input = let x = complicated_function input in object val y = another function x (* those imaginary methods again... *) end 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. Thanks much, John