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 75AC8BC0A for ; Fri, 22 Dec 2006 16:22:52 +0100 (CET) Received: from pih-relay06.plus.net (pih-relay06.plus.net [212.159.14.133]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBMFMpsB012413 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Fri, 22 Dec 2006 16:22:52 +0100 Received: from [80.229.56.224] (helo=[10.0.0.5]) by pih-relay06.plus.net with esmtp (Exim) id 1GxmEV-0000nl-6B for caml-list@yquem.inria.fr; Fri, 22 Dec 2006 15:22:51 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Scripting in ocaml Date: Fri, 22 Dec 2006 15:20:30 +0000 User-Agent: KMail/1.9.5 References: <6dbd4d000612201941wcd4b09anc503a13889576512@mail.gmail.com> <458AF864.20902@hq.idt.net> <1166755864.6135.70.camel@rosella.wigram> In-Reply-To: <1166755864.6135.70.camel@rosella.wigram> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200612221520.30939.jon@ffconsultancy.com> X-j-chkmail-Score: MSGID : 458BF84B.002 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 458BF84B.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 bug:01 run-time:01 statically:01 optimising:01 optimising:01 compiler:01 bytecode:01 inherently:01 optimise:01 generality:01 ocaml:01 run-time:01 overloading:01 annotations:01 On Friday 22 December 2006 02:51, skaller wrote: > Just BTW .. it is very bad to raise exceptions on type errors. For what definition of "type"? > 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. Absolutely. But the ability to do run-time dispatch based upon type is an advantage of dynamic typing, so it is something that you do not want to lose. > For example this destroys the ability to analyse Python > statically for the purpose of optimising it. Yes. An optimising Python compiler will only be adopted/useful if it can evaluate any Python. Note that this could mean reverting to interpreted bytecode when the program is inherently dynamically typed. > 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. You can raise exceptions from unexpectedly typed code whilst keeping the advantages of static checking and performance in F#, for example. This gives you the advantages of both worlds: performance/reliability when leveraging static typing and brevity/generality when leveraging dynamic typing. For example, I recently benchmarked C++, F#, OCaml and Python for computing discrete wavelet transforms. F# (on 32-bit WXP) was slightly faster than OCaml (on 64-bit Debian), so it can have very competitive performance: http://groups.google.co.uk/group/comp.lang.python/msg/0229d2c6484ea491?hl=en& http://groups.google.co.uk/group/comp.lang.python/msg/daf7bbb2bd7e99f3?hl=en& Yet F# retains run-time type information so you can use a generic print function (print_any) on any type, have your dynamic code loading and so on. The best of both worlds. On a related note, F# supports operator overloading, which greatly simplifies many mathematical expressions at the cost of requiring more type annotations. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists