Re: initialization of instance variables

From: John Whitley (
Date: Thu Apr 01 1999 - 17:01:55 MET DST

From: John Whitley <>
Date: Thu, 1 Apr 1999 10:01:55 -0500 (EST)
Subject: Re: initialization of instance variables
In-Reply-To: <>

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

(* prohibited form *)
class foo input =
  val x = complicated_function input
  val y = another_function x
  (* imagine some methods... *)

(* a working, let-bound form *)
class foo' input =
let x = complicated_function input in
  val y = another function x
  (* those imaginary methods again... *)

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,

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:21 MET