Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: John Whitley <whitley@cse.buffalo.edu>
To: caml-list@inria.fr
Subject: Re: initialization of instance variables
Date: Thu,  1 Apr 1999 10:01:55 -0500 (EST)	[thread overview]
Message-ID: <14083.34604.727325.126299@hadar.cse.Buffalo.EDU> (raw)
In-Reply-To: <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




  reply	other threads:[~1999-04-01 18:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-27 18:04 John Whitley
1999-04-01 13:10 ` Jerome Vouillon
1999-04-01 15:01   ` John Whitley [this message]
1999-04-03 10:40     ` Hendrik Tews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14083.34604.727325.126299@hadar.cse.Buffalo.EDU \
    --to=whitley@cse.buffalo.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox