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 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 4EF08BC0B for ; Wed, 17 Jan 2007 23:54:55 +0100 (CET) Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0HMssUk027094 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 17 Jan 2007 23:54:55 +0100 Received: from [80.229.56.224] (helo=[10.0.0.5]) by ptb-relay02.plus.net with esmtp (Exim) id 1H7JgB-0002EN-Ud for caml-list@yquem.inria.fr; Wed, 17 Jan 2007 22:54:52 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Polymorphic Variants Date: Wed, 17 Jan 2007 22:53:13 +0000 User-Agent: KMail/1.9.5 References: <20070117.111927.2004173151.garrigue@math.nagoya-u.ac.jp> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200701172253.13837.jon@ffconsultancy.com> X-Miltered: at discorde with ID 45AEA93E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; variants:01 overloading:01 annotations:01 sqrt:01 sqrt:01 quirks:01 overloading:01 ocaml:01 variants:01 inference:01 run-time:01 ocaml:01 frog:98 polymorphic:01 polymorphic:01 On Wednesday 17 January 2007 21:13, Tom wrote: > Any comments? Yes: I prefer things the way they are. You can add overloading to ML but you must then add lots of type annotation= s=20 to your code. For example, vector length: let length (x, y) =3D sqrt(x*.x +. y*.y) becomes: let length (x : float, y : float) =3D sqrt(x*x + y*y) So you've saved the "." three times at the cost of ": float" twice because = the=20 overloaded * and + don't provide enough type information. You can complicat= e=20 the type inferer to counteract this but then other type errors will become= =20 increasingly obscure and the programmer will be forced to learn the quirks= =20 that you've added in order to debug their code. Constructor overloading can be done in OCaml using polymorphic variants. Th= ey=20 are slower. Code written in this style quickly becomes unmaintainable becau= se=20 the type errors (from inference) are so complicated that you are forced to= =20 annotate types. =46inally, I don't want my types discovered at run-time because it makes my= code=20 slower and uses more memory. I'd rather have to box manually, so fast code = is=20 concise code. =46rom my point of view, your suggestions are mostly steps backwards (towar= ds=20 Lisp, C++ etc.). I think the best way to improve OCaml is to write an IDE that sidesteps the= se=20 problems, e.g. by typesetting the code "+." as "+". =2D-=20 Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists