From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id FAA23302; Tue, 12 Jun 2001 05:21:21 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 FAA23103 for ; Tue, 12 Jun 2001 05:21:20 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f5C3LHD24396; Tue, 12 Jun 2001 05:21:18 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id MAA23269; Tue, 12 Jun 2001 12:21:15 +0900 (JST) To: Pierre.Weis@inria.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] let mutable (was OCaml Speed for Block Convolutions) In-Reply-To: <200106111342.PAA12420@pauillac.inria.fr> References: <01060821302901.00670@haguenauer> <200106111342.PAA12420@pauillac.inria.fr> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010612122114X.garrigue@kurims.kyoto-u.ac.jp> Date: Tue, 12 Jun 2001 12:21:14 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Pierre Weis > > > This construction would have introduced the notion of > > > Lvalue in Caml, thus introducing some additional semantics complexity, > > > and a new notion to explain to beginners. > > > > Lvalues already exist in Ocaml (and have to be explained to > > beginners), for example : "a.(i) <- a.(i)+1". > > I'm afraid this is wrong. > > The syntactic construction e1.(e2) <- e3 is a short hand for a > function call: Array.set e1 e2 e3. Once more there is no Lvalue here, > just a regular function call (hence you can write arbitrary complex > expressions in place of e1, provided it returns an array value). > > I'm a bit surprised that you feel it necessary to explain the notion > of Lvalue to beginners when there is no such notion in the language ! You can of course explain the semantics this way, but most people apparently consider that there are lvalues in ocaml, just that they are very restricted. It is certainly much simpler to explain than lvalues in C! Also, there is one unique case currently which can only be explained by the distinction lvalue/rvalue: instance variables in objects. class counter = object val mutable x = 0 method get = x method bump = x <- x + 1 end How can you explain the method bump without the notion of lvalue? Perfectly coherent answers would be, let's remove mutable instance variables, or force the notation self.x to access variables. Another answer is that people so fond of objects have already heared of lvalues anyway. the problem is not only with lvalues either. With for loops, you have a case of rvalue, where something which is not syntactically a function have a changing variable, which is accessed directly. The fact you cannot change it yourself is not relevant. Best regards, Jacques Garrigue ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr