From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 37E9EBB81 for ; Sun, 12 Dec 2004 00:29:42 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBBNTf14020834 for ; Sun, 12 Dec 2004 00:29:41 +0100 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 AAA02957 for ; Sun, 12 Dec 2004 00:29:41 +0100 (MET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBBNTcPb020823 for ; Sun, 12 Dec 2004 00:29:40 +0100 Received: from [192.168.1.200] (ppp203-65.lns1.syd3.internode.on.net [203.122.203.65]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id iBBNTK0r009268; Sun, 12 Dec 2004 09:59:27 +1030 (CST) Subject: Re: [Caml-list] environment idiom From: skaller Reply-To: skaller@users.sourceforge.net To: Andrej Bauer Cc: caml-list In-Reply-To: <41BB04D8.60405@andrej.com> References: <9410EC84C0872141B27A2726613EF45D02A52E08@psmrdcex01.psm.pin.safeco.com> <41B97FD7.50309@andrej.com> <1102732237.2611.580.camel@pelican.wigram> <41BB04D8.60405@andrej.com> Content-Type: text/plain Message-Id: <1102807759.2611.609.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 12 Dec 2004 10:29:20 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41BB82E5.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41BB82E2.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 andrej:01 wrote:01 minor:01 const:01 pointers:01 ocaml:01 ocaml:01 compiler:01 compiler:01 verbose:01 glebe:01 061:98 idiom:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Sun, 2004-12-12 at 01:31, Andrej Bauer wrote: > It seems that John Skaller and I have different experiences, Yes but I came to almost the same conclusion as you. I agree with your basic premise, I propose only a minor amendment, possibly more suitable for 'programming-in-the-large'. > He offers a C/C++ example of the > const pointers. I am not convinced that ocaml and C/C++ are comparable > in this respect. The principle is quite general, exceeding not only C++/Ocaml, but applying way beyond programming. I actually learned this idea, that one should think about how a code base will cope with change, in a superb book on Cobol programming. More recently, Bertrand Meyer stated the Open/Closed principle, which deals with a related issue. As an example: this code is fragile: for(int i =0; i!=10; ++i)a[i]=b[i]; because it terminates *precisly* at the expected array length. It will fail for any change in array length. Fragile coding is good sometimes, and other times you would prefer your code to be robust. To some extent it depends on the use of your code and how much money you have to finish the program. For a quick and dirty program, you'd make it robust. If it's a library that is intended to be heavily used, you make it fragile. > I habitually abuse the ocaml compiler to tell me > precisely what needs to be changed in the following way: I change a type > or value definition (say, change the arguments to a function) and keep > running the compiler until it reports errors, fixing them as they come > up. I do that too. Heavily. Only I don't think of it as abuse :) Unfortunately some things in a compiler seem to demand run time checks where you'd much prefer static typing. However the strongest static typing is very hard to get exactly right, and is quite verbose. I'd spend more time fiddling with it when things changed, than modifying the algorithms which actually do the work. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net