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 UAA07397 for caml-redistribution; Thu, 1 Apr 1999 20:39:12 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA16775 for ; Thu, 1 Apr 1999 15:10:17 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id PAA10934; Thu, 1 Apr 1999 15:10:15 +0200 (MET DST) Received: (from vouillon@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA05414; Thu, 1 Apr 1999 15:10:14 +0200 (MET DST) Message-ID: <19990401151014.56489@pauillac.inria.fr> Date: Thu, 1 Apr 1999 15:10:14 +0200 From: Jerome Vouillon To: John Whitley , caml-list@inria.fr Subject: Re: initialization of instance variables References: <14077.2636.294799.938058@hadar.cse.Buffalo.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mutt 0.89.1 In-Reply-To: <14077.2636.294799.938058@hadar.cse.Buffalo.EDU>; from John Whitley on Sat, Mar 27, 1999 at 01:04:33PM -0500 Sender: weis On Sat, Mar 27, 1999 at 01:04:33PM -0500, John Whitley wrote: > > I'm curious as to why class instance variable definitions cannot be > used in following instance variable definitions, only in methods and > initializers. Is this an implmentation-driven restriction, or is > there some more subtle semantics-based reason to prevent this? 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. Indeed, an identifier "x" in a method definition stands for the current value of the instance variable "x" whereas, in an instance variable definition, it would stand for the initial definition of the instance variable. For instance, if "o" is an object of the class "c" below, the expression "o#get_y ()" will always evaluate to 1, whereas the expression "o#get_x ()" will evaluate to 2 if the method "set" was invoked previously. class c = object val mutable x = 1 method set = x <- 2 method get_x () = x val y = fun () -> x method get_y = y end -- Jérôme