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 PAA29871 for caml-red; Fri, 22 Dec 2000 15:25:34 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA27513; Fri, 22 Dec 2000 15:22:50 +0100 (MET) From: Pierre Weis Message-Id: <200012221422.PAA27513@pauillac.inria.fr> Subject: Re: Ref syntax In-Reply-To: <20001222183020R.garrigue@kurims.kyoto-u.ac.jp> from Jacques Garrigue at "Dec 22, 100 06:30:20 pm" To: garrigue@kurims.kyoto-u.ac.jp (Jacques Garrigue) Date: Fri, 22 Dec 2000 15:22:50 +0100 (MET) Cc: caml-list@pauillac.inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis@pauillac.inria.fr > Really, I don't think it would be useful at toplevel. > I view let mutable .. in as a way to provide some state, but > immediately cleanly wrapped, either by only being used locally, or > in exported functions. > This is completely similar to mutable object fields; both the goal and > the method. I hope this is effectively simple to type check, and ensure correct. > > For instance, what do we > > do if such a letref variable is assigned to, from within the body of a > > function (that could be exported) ? > > This is just syntactic sugar for references, which is why I said it > was easy. Similarly typing is just the typing of references. So you mean, that if we define x with let mutable x = 1, the variable x has in fact type int ref ? > > Furthermore, this construct would add an entirely > > new notion to Caml: lvalues. > > As stated above: they are already here, object fields. > You may think of it as a good or bad idea, but the distinction > between it and the fact a.x behaves differently when there is a <- and > when there is none is subtle. Sorry, but for field mutations the syntactic construct is not expr <- new_val but expr.label <- new_val which is semantically assign_to_label (expr, new_val), as expr.(i) <- new_val is a short-hand for assign_to_vector (expr, i, new_val). In both constructs there is no notion of left values. I really don't know if the corresponding notion for objects needs lvalues or not. > But well, this was only first in my wish list because I was answering > to a message related to that. My personal priority is much lower. I think exactly the same: the let mutable (or var construct as we used to call it) is desirable, but may not be worth the implementation effort. [...] > > So you are already satisfied, since you can write > > > > ocamlc -c -I +camltk -I +camlimages ocaml_unreal_t.ml > > > > in the current development version! > > Great! I had seen the introduction of -where, but didn't catch this > one. > Thanks, Papa Weis ! > > Jacques Hey, this is your ``Santa Xavier's'' work. Thanks to him. Cheers, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/