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 TAA30414 for caml-redist; Fri, 12 May 2000 19:09:36 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA31053 for ; Thu, 11 May 2000 20:59:49 +0200 (MET DST) Received: from babbage.ececs.uc.edu (mail.ececs.uc.edu [129.137.8.2]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e4BIxZP01286; Thu, 11 May 2000 20:59:44 +0200 (MET DST) Received: from gatekeeper-internal.ececs.uc.edu (gatekeeper-internal.ececs.uc.edu [129.137.8.10]) by babbage.ececs.uc.edu (8.9.3+Sun/8.9.3) with ESMTP id OAA19200; Thu, 11 May 2000 14:59:16 -0400 (EDT) Date: Thu, 11 May 2000 14:59:16 -0400 (EDT) From: Hongwei Xi To: Pierre Weis cc: caml-list@inria.fr Subject: Re: reference initialization In-Reply-To: <200005111358.PAA03140@pauillac.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis Okay, I withdraw my argument that the Java strategy is better then the ML strategy However, I'd like to use the following example to make my point clear. I want to combine two arrays into one. Here is the code in OCaml. let combine_arrays a b = let alen = Array.length a in let blen = Array.length b in let c = Array.make (alen + blen) ? in begin for i = 0 to alen - 1 do c.(i) <- a.(i) done; for i = 0 to blen -1 do c.(alen + i) <- b.(i) done end Of course, you need to provide ? to make the above code work. Here is my argument: (1) If you try to provide ?, the code becomes repulsive. (2) If you really want to make sure that 'c' is well-initialized, you should probably check this after those two loops. The question is how to incorporate the checking result into the type system. (3) If you initialize 'c' with a (wrong) value, it seems to me that nothing is achieved. (4) Also, the problem cannot be solved using option type. This is a precise senario that I had in mind, where the kind of mandatory array initialization in ML-like langugages is simply inappropriate, isn't it? Cheers, --Hongwei \~~~~/ \\ // \\ // @ Mail: hwxi@ececs.uc.edu C-o^o, ))__|| \\__//_ // \\ Url: http://www.ececs.uc.edu/~hwxi ( ^ ) ))__|| \--/-\\ \\ / \V\ )) || // \\ \\ Tel: +1 513 556 4762 (office) ------ // || o // \\ \\//Fax: +1 513 556 7326 (department)