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=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 87EFFBC0A for ; Fri, 22 Dec 2006 19:16:54 +0100 (CET) Received: from ipmail02.adl2.internode.on.net (ipmail02.adl2.internode.on.net [203.16.214.141]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBMIGqo5018300 for ; Fri, 22 Dec 2006 19:16:53 +0100 Received: from ppp14-213.lns2.syd7.internode.on.net (HELO rosella) ([59.167.14.213]) by ipmail02.adl2.internode.on.net with ESMTP; 23 Dec 2006 04:46:48 +1030 X-IronPort-AV: i="4.12,205,1165152600"; d="scan'208"; a="63784702:sNHT22864541" Subject: Re: strong/weak typing terminology (was Re: [Caml-list] Scripting in ocaml) From: skaller To: Tom Cc: Daniel =?ISO-8859-1?Q?B=FCnzli?= , caml-list@yquem.inria.fr In-Reply-To: References: <6dbd4d000612201941wcd4b09anc503a13889576512@mail.gmail.com> <20061221153413.8f99e8ed.mle+ocaml@mega-nerd.com> <1166685756.5337.4.camel@rosella.wigram> <458A8C7B.7050204@hq.idt.net> <1166709162.5653.11.camel@rosella.wigram> <458AA143.3090303@hq.idt.net> <20061221202520.GG9440@apotheon.com> <20061221221650.GL9440@apotheon.com> <3EC73FC3-41A6-4FB1-9549-29286A6568CC@epfl.ch> Content-Type: text/plain Date: Sat, 23 Dec 2006 05:16:43 +1100 Message-Id: <1166811403.6555.46.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 458C2114.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 0100,:01 statically:01 haskell:01 ocaml:01 bug:01 arrays:01 optimising:01 bug:01 hashtbl:01 deliberate:98 compilers:01 sourceforge:01 wrote:01 dynamically:01 On Fri, 2006-12-22 at 17:51 +0100, Tom wrote: > > Later he gives the following chart > > |Statically checked | Dynamically checked > ------------------------------------------------- > safe | ML, Haskell, Java, etc. | Lisp, Scheme, Perl, > Postscript, etc > unsafe | C, C++, etc. | > > > But this chart is not expressive enough... It is also unclear what you mean by 'unsafe'. Ocaml is not safe: let a = Array.create 0 0 in let y = a.[99] in (* WOOPS *) The fact that an exception is thrown may or may not make the language safe depending on whether or not you INTEND to trigger an exception. The best you can say is that if you don't catch it, its a bug. Otherwise, you have to read the comments to know if the out of bounds access was deliberate .. something compilers can't do very easily. In fact C arrays are safer precisely because the behaviour is not defined. That way you KNOW an out of bound access is an error, so reasoning about the code .. and optimising it .. is easier. Furthermore you can always enable array bounds checking with an instrumentation switch or tool like Purify. Well array bounds probably aren't contentious: most people would say an access violation was a bug, even in Ocaml. But you can't be so sure with try Some (Hashtbl.find table key) with Not_found -> None That doesn't look like a bug, if the key isn't found. There's a difference in intent .. but the language fails to express it. Exceptions and specified dynamic checks are 'evil' :) -- John Skaller Felix, successor to C++: http://felix.sf.net