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=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id AB647BC69 for ; Thu, 8 Mar 2007 21:02:24 +0100 (CET) Received: from mail.roomandboard.com (mail.roomandboard.com [66.84.219.55]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l28K2Lil024291 for ; Thu, 8 Mar 2007 21:02:23 +0100 Received: from selma.roomandboard.com ([192.168.101.46]) by mail.roomandboard.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 8 Mar 2007 14:02:21 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Operator overloading Date: Thu, 8 Mar 2007 14:02:21 -0600 Message-ID: <3D1E4D9CA9BCE04D8F2B55F203AE4CE30666AB74@selma.roomandboard.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [Caml-list] Operator overloading Thread-Index: AcdhvK6DYaDkMoMCSXGjq7l+L1jltA== From: "Robert Fischer" To: X-OriginalArrivalTime: 08 Mar 2007 20:02:21.0357 (UTC) FILETIME=[AE8CFDD0:01C761BC] X-Miltered: at concorde with ID 45F06BCD.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; overloading:01 vectors:01 matrices:01 overloading:01 compiler:01 ocaml:01 ocaml:01 functors:01 functor:01 functors:01 vectors:01 matrices:01 syntax:01 beginner's:01 bug:01 > For example, I often define +| for vectors, +|| for matrices, *| for=20 > scalar-matrix multiplication, *|| for vector-matrix and *||| for=20 > matrix-matrix. I also want to support complex numbers and symbolic=20 > expressions and I don't particularly want to remember and document 50 = numeric=20 > operators, nor explain their existence to my customers... > Which is exactly my point. You should have to document all that, = because they are genuinely different operations. You have these = operations, so why shouldn't you document them? Or, better yet, = abstract them and organize them. By using operator overloading, you're = sweeping under the rug genuine complexity -- something that my surprise = later developers! When I see "+", I want to know what that means. With operator = overloading, I don't know. An IDE might help me out there, but that's = just polishing a genuine ding on code readbility and maintainability. = Why should I have to rely on an IDE to make sense of my code? If I have a typing issue in my code, I want the compiler balk at where = the problem is. The best I can hope for with operator overloading is = that the result type is caught through a failure of duck typing shortly = down the pipeline -- but that very safety would is undermined if "down = the pipeline" also uses lots of operator overloading. I'm very sure that you can code with operator overloading and be = productive. The person writing the code probably even feels like it's a = productivity and readability boon. But I see maintainability as a big = problem here. As far as I'm concerned, if two things do different = things, they should have different names. You can give them funny names = like "+|", but it should still be different names. ~~ Robert. -----Original Message----- From: caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr]On Behalf Of Jon Harrop Sent: Thursday, March 08, 2007 1:41 PM To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Operator overloading 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=20 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:=20 operator overloading and template metaprogramming for low-dimensional = vector=20 and matrix operations. The latter can be addressed by autogenerating = code.=20 The former cannot be addressed in the current OCaml. For example, I often define +| for vectors, +|| for matrices, *| for=20 scalar-matrix multiplication, *|| for vector-matrix and *||| for=20 matrix-matrix. I also want to support complex numbers and symbolic=20 expressions and I don't particularly want to remember and document 50 = numeric=20 operators, nor explain their existence to my customers and I certainly = don't=20 appreciate reading expressions written in this syntax. --=20 Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs