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 53BD9BC83 for ; Fri, 9 Mar 2007 11:37:25 +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 l29AbO8U020430 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Fri, 9 Mar 2007 11:37:25 +0100 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay02.plus.net with esmtp (Exim) id 1HPcTS-0005Mb-39 for caml-list@yquem.inria.fr; Fri, 09 Mar 2007 10:37:23 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Operator overloading Date: Fri, 9 Mar 2007 10:31:24 +0000 User-Agent: KMail/1.9.5 References: <3D1E4D9CA9BCE04D8F2B55F203AE4CE30666AB80@selma.roomandboard.com> In-Reply-To: <3D1E4D9CA9BCE04D8F2B55F203AE4CE30666AB80@selma.roomandboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200703091031.25088.jon@ffconsultancy.com> X-Miltered: at discorde with ID 45F138E4.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; overloading:01 ocaml:01 ocaml:01 20,:98 frog:98 wrote:01 caml-list:01 arithmetic:01 int:01 types:03 let:03 let:03 expressions:04 hack:04 vector:05 On Thursday 08 March 2007 23:20, Robert Fischer wrote: > > let result = > > let (+) = Vector.add and ( * ) (x:int) (v:Vector.t) = > > Vector.scalarmul x v > > in 3 * a + 2 * b > > I didn't realize that existed. It's not so bad -- it lets me have my > cake and Jon eat it, too. :D I've been using that style for years and it just doesn't hack it. Firstly, note the verbosity compared to: let result = 3*a + 2*b then note that many arithmetic expressions mix types, so you still end up needing +, +., +/, +| and +||. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists