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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 59A67BC0A for ; Fri, 22 Dec 2006 03:51:12 +0100 (CET) Received: from ipmail02.adl2.internode.on.net (ipmail02.adl2.internode.on.net [203.16.214.141]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBM2p9V7030530 for ; Fri, 22 Dec 2006 03:51:11 +0100 Received: from ppp14-213.lns2.syd7.internode.on.net (HELO rosella) ([59.167.14.213]) by ipmail02.adl2.internode.on.net with ESMTP; 22 Dec 2006 13:21:07 +1030 X-IronPort-AV: i="4.12,202,1165152600"; d="scan'208"; a="63570037:sNHT26563306" Subject: Re: [Caml-list] Scripting in ocaml From: skaller To: Serge Aleynikov Cc: Chad Perrin , caml-list@yquem.inria.fr In-Reply-To: <458AF864.20902@hq.idt.net> 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> <458AF864.20902@hq.idt.net> Content-Type: text/plain Date: Fri, 22 Dec 2006 13:51:04 +1100 Message-Id: <1166755864.6135.70.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 458B481D.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 runtime:01 runtime:01 bug:01 statically:01 optimising:01 optimise:01 sourceforge:01 wrote:01 wrote:01 typing:01 integer:01 exception:01 caml-list:01 exceptions:01 On Thu, 2006-12-21 at 16:11 -0500, Serge Aleynikov wrote: > Chad Perrin wrote: > What I meant by "strict typing" was performing type checks *at runtime*, > i.e. that there are no unsafe operations. > > Say, as an example, doing type checks of function arguments at runtime: > > let f = fun i when is_integer (i) -> i > | x when is_float (x) -> int_of_float x;; > > (raising Bad_match of some sort if neither one of the two guards pass) > Just BTW .. it is very bad to raise exceptions on type errors. The program should be aborted. The reason is that raising such exceptions also allows for catching them, which means doing a type error is no longer unsafe and no longer a bug, but a legitimate technique. This in turn defeats most static type analysis you might do. For example this destroys the ability to analyse Python statically for the purpose of optimising it. It is *essential* that the language description not mandate raising exceptions on type errors, but rather specify the action is undefined .. even if the implementation raises an exception, the language specification must NOT require that. This prevents programmers actually relying on it and allows a static analyser to optimise the code on the assumption it is well typed. -- John Skaller Felix, successor to C++: http://felix.sf.net