From: John Whitley <whitley@cse.buffalo.edu>
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>
<19990401151014.56489@pauillac.inria.fr>
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
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:21 MET