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 74569BC69 for ; Thu, 8 Mar 2007 20:46:39 +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 l28JkcKu027545 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 8 Mar 2007 20:46:39 +0100 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay02.plus.net with esmtp (Exim) id 1HPOZR-0003J9-HJ for caml-list@yquem.inria.fr; Thu, 08 Mar 2007 19:46:38 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Operator overloading Date: Thu, 8 Mar 2007 19:40:42 +0000 User-Agent: KMail/1.9.5 References: <3D1E4D9CA9BCE04D8F2B55F203AE4CE30666AB5E@selma.roomandboard.com> <45F04DD0.5010505@janestcapital.com> In-Reply-To: <45F04DD0.5010505@janestcapital.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200703081940.42856.jon@ffconsultancy.com> X-Miltered: at discorde with ID 45F0681E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; overloading:01 ocaml:01 overloading:01 ocaml:01 functors:01 functor:01 functors:01 vectors:01 matrices:01 syntax:01 frog:98 wrote:01 wrote:01 imho:01 caml-list:01 On Thursday 08 March 2007 17:54, Brian Hurt wrote: > Roland Zumkeller wrote: > > Wasn't there a more or less good reason for OCaml *not* to support > > operator overloading? > > Yes. Ocaml has modules and functors. IMHO, any time you thing "boy, > it'd be really nice to use operator overloading here", you should use a > module and a functor instead. > ... For me, operator overloading is about clarity. In the absence of operator overloading, you cannot regain the lost clarity using modules and functors. This is one of the two things I missed when I moved from C++ to OCaml: operator overloading and template metaprogramming for low-dimensional vector and matrix operations. The latter can be addressed by autogenerating code. The former cannot be addressed in the current OCaml. For example, I often define +| for vectors, +|| for matrices, *| for scalar-matrix multiplication, *|| for vector-matrix and *||| for matrix-matrix. I also want to support complex numbers and symbolic expressions and I don't particularly want to remember and document 50 numeric operators, nor explain their existence to my customers and I certainly don't appreciate reading expressions written in this syntax. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists