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 VAA29247; Fri, 8 Jun 2001 21:32:31 +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 VAA29488 for ; Fri, 8 Jun 2001 21:32:30 +0200 (MET DST) Received: from medianet-1v.grolier.fr (medianet-1v.grolier.fr [194.158.98.201]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f58JWUn20907 for ; Fri, 8 Jun 2001 21:32:30 +0200 (MET DST) Received: from haguenauer.dijon.fr ([212.225.129.243]) by medianet-1v.grolier.fr (8.9.3+Sun/8.9.3) with ESMTP id VAA25944 for ; Fri, 8 Jun 2001 21:32:05 +0200 (CEST) Received: from localhost (localhost [[UNIX: localhost]]) by haguenauer.dijon.fr (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f58JUTu01551 for caml-list@inria.fr; Fri, 8 Jun 2001 21:30:29 +0200 From: Michel Quercia Reply-To: michel.quercia@prepas.org To: caml-list@inria.fr Subject: Re: [Caml-list] let mutable (was OCaml Speed for Block Convolutions) Date: Fri, 8 Jun 2001 21:30:29 +0200 X-Mailer: KMail [version 1.1.99] Content-Type: text/plain; charset="US-ASCII" References: <200106081730.TAA27320@pauillac.inria.fr> In-Reply-To: <200106081730.TAA27320@pauillac.inria.fr> MIME-Version: 1.0 Message-Id: <01060821302901.00670@haguenauer> Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le Vendredi 8 Juin 2001 19:30, Pierre Weis a écrit : > The introduction of a ``let mutable'', more concisely noted with the > var keyword, is not new: it has been discussed in the Caml groups 3 or > 4 years ago. We chose to abandon it for sake of semantics simplicity > of the language. For beginners (f.e. students) things look a bit complicated : (* summing up all elements of an integer array *) let adda a = let res = ref 0 in let i = ref 0 in while !i < Array.length(a) do res := !res+a.(!i); i := !i+1 done; !res ;; A lot of boring exclam, but that's the price to pay for having mutable values, and that's logical. Okay ... (* same, but with a for loop *) let add_1 a = let res = ref 0 in for i=0 to Array.length(a)-1 do res := !res + a.(i) done; !res ;; No exclam and no ref for i ? And its value is changing though ? Where is gone the logic ? > 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". Regards, -- Michel Quercia 23 rue de Montchapet, 21000 Dijon http://pauillac.inria.fr/~quercia mailto:michel.quercia@prepas.org ------------------- 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