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=1.2 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL 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 061D8BC0C for ; Thu, 18 Jan 2007 00:07:16 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0HN7FZ6000483 for ; Thu, 18 Jan 2007 00:07:15 +0100 Received: by ug-out-1314.google.com with SMTP id q2so15814uge for ; Wed, 17 Jan 2007 15:07:15 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=ihwS4CzwKtQvmcnUJKBBzt8EndNSzoYJOKtgKrNnO3PU7m+tD5BzpzX/whUwjHuf15ifNohmZtqHHv7PYba9a8emkBOCEE0dzzWx++EM+VltbnoN8KB7TIaQhjKLhdlwvo+eEMA0uj5NCXZLYPtyBpuEV4GJ+aC7Tmfr3E5D5Dk= Received: by 10.82.114.3 with SMTP id m3mr34219buc.1169075234589; Wed, 17 Jan 2007 15:07:14 -0800 (PST) Received: by 10.82.175.13 with HTTP; Wed, 17 Jan 2007 15:07:14 -0800 (PST) Message-ID: Date: Thu, 18 Jan 2007 00:07:14 +0100 From: Tom To: "Jon Harrop" Subject: Re: [Caml-list] Polymorphic Variants Cc: caml-list@yquem.inria.fr In-Reply-To: <200701172253.13837.jon@ffconsultancy.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_72839_15534694.1169075234261" References: <20070117.111927.2004173151.garrigue@math.nagoya-u.ac.jp> <200701172253.13837.jon@ffconsultancy.com> X-j-chkmail-Score: MSGID : 45AEAC23.001 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45AEAC23.001 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 compiler:01 infers:01 compiler:01 overload:01 run-time:01 variants:01 overloading:01 annotations:01 quirks:01 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_72839_15534694.1169075234261 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline > > > Yes: I prefer things the way they are. I don't mean an revolution. Rather a symbiosys. You can add overloading to ML but you must then add lots of type annotations > to your code. For example, vector length: > > let length (x, y) = sqrt(x*.x +. y*.y) > > becomes: > > let length (x : float, y : float) = sqrt(x*x + y*y) > > So you've saved the "." three times at the cost of ": float" twice because > the > overloaded * and + don't provide enough type information. You can > complicate > the type inferer to counteract this but then other type errors will become > increasingly obscure and the programmer will be forced to learn the quirks > that you've added in order to debug their code. 3 solutions: * sqrt has type of float -> float and the compiler infers float arguments * you write +. and *. (at least once) (those operators could be still available, don't you think so?) * let the compiler overload your function ( length : (int * int) -> float; length : (float * float) -> float) and then drop the "int" one as you never ever used it in your code. > Finally, I don't want my types discovered at run-time because it makes my > code > slower and uses more memory. I'd rather have to box manually, so fast code > is > concise code. More memory is used by polymorphic variants too. And the records could be optimised so that type information is only added when it is needed by the programm. >>From my point of view, your suggestions are mostly steps backwards (towards > Lisp, C++ etc.). Thank you for your comment :) - Tom ------=_Part_72839_15534694.1169075234261 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline

Yes: I prefer things the way they are.

I don't mean an revolution. Rather a symbiosys.

You can add overloading to ML but you must then add lots of type annotations
to your code. For example, vector length:

  let length (x, y) = sqrt(x*.x +. y*.y)

becomes:

  let length (x : float, y : float) = sqrt(x*x + y*y)

So you've saved the "." three times at the cost of ": float" twice because the
overloaded * and + don't provide enough type information. You can complicate
the type inferer to counteract this but then other type errors will become
increasingly obscure and the programmer will be forced to learn the quirks
that you've added in order to debug their code.

3 solutions:
  * sqrt has type of float -> float and the compiler infers float arguments
  * you write +. and *. (at least once) (those operators could be still available, don't you think so?)
  * let the compiler overload your function ( length : (int * int) -> float; length : (float * float) -> float) and then drop the "int" one as you never ever used it in your code.
 
Finally, I don't want my types discovered at run-time because it makes my code
slower and uses more memory. I'd rather have to box manually, so fast code is
concise code.

More memory is used by polymorphic variants too. And the records could be optimised so that type information is only added when it is needed by the programm.

From my point of view, your suggestions are mostly steps backwards (towards
Lisp, C++ etc.).

Thank you for your comment :)

- Tom
------=_Part_72839_15534694.1169075234261--