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