From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 381B4BC69 for ; Wed, 11 Apr 2007 07:08:15 +0200 (CEST) Received: from dedibox1.ambre.net (dedibox1.ambre.net [88.191.29.66]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3B58Ehd015651 for ; Wed, 11 Apr 2007 07:08:15 +0200 Received: from [192.168.0.1] (lau18-1-82-246-197-195.fbx.proxad.net [82.246.197.195]) by dedibox1.ambre.net (Postfix) with ESMTP id 1889A114C162 for ; Wed, 11 Apr 2007 07:08:11 +0200 (CEST) Subject: RE: [Caml-list] Read-only arrays ? From: David Teller To: OCaml In-Reply-To: References: <509223F0BF55E74FA1247D17207E7A0C014E5043@orsmsx419.amr.corp.intel.com> Content-Type: text/plain Date: Wed, 11 Apr 2007 07:08:09 +0200 Message-Id: <1176268090.27607.9.camel@Blefuscu> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 461C6D3E.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; read-only:01 arrays:01 univ-orleans:01 abstracted:01 cheers:01 read-only:01 arrays:01 ocaml's:01 mutable:01 cheers:01 beginner's:01 ocaml:01 bug:01 univ-orleans:01 lifo:01 In my case, I'm writing a small board game my students will need to complete in an assignment. So, I can trust that, if something can go wrong, they'll find a way to make it happen. Essentially, the board is a matrix, abstracted in a module. Among other things, module Board provides * a type Board.square of squares * a type Board.t of boards (internally defined as a Board.square array array) * a conversion function Board.to_array : Board.t -> Board.square array array (a copy function for the matrix) * a conversion function Board.from_array : Board.square array array -> Board.t (a copy function for the matrix) While performance is hardly critical, it's intellectually unsatisfying to have and copy the whole board each time the borders of the module are crossed, just to ensure that my students won't do anything wrong enough to break the module. Cheers, David On Tue, 2007-04-10 at 16:12 -0700, Martin Jambon wrote: > On Tue, 10 Apr 2007, Harrison, John R wrote: > > > | This topic comes up from time to time... My take on this is that > > read-only > > | arrays or strings are not badly needed. > > > > Of course, this is a matter of opinion. In the end you didn't offer > > a solution to the specific problem I had. I'll still need to adopt > > an expensive and/or ugly workaround if I really want to protect myself > > against OCaml's mutable strings. However, I accept that my application > > is not typical. > > It seems to me that you don't have a problem, but you imagine you have > one... which is much better than the other way around :-) > > http://caml.inria.fr/pub/ml-archives/caml-list/2006/05/f603bc5e2fec357d8a36d807664072e6.en.html > > > Cheers, > > Martin > > -- > Martin Jambon > http://martin.jambon.free.fr > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs -- David Teller ------------------------------------------ Security of Distributed Systems ----------------------- -- http://www.univ-orleans.fr/lifo/Members/David.Teller ----- Laboratoire d'Informatique Fondamentale d'Orleans