From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id B98A0BC48 for ; Sat, 9 Apr 2005 04:58:12 +0200 (CEST) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j392wCu3012275 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 9 Apr 2005 04:58:12 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay03.plus.net with esmtp (Exim) id 1DK6Al-000E9l-Sa for caml-list@yquem.inria.fr; Sat, 09 Apr 2005 02:58:11 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] ambitious proposal: polymorphic arithmetics Date: Sat, 9 Apr 2005 03:58:37 +0100 User-Agent: KMail/1.7.1 References: <20050406.111505.68543084.eijiro_sumii@anet.ne.jp> In-Reply-To: <20050406.111505.68543084.eijiro_sumii@anet.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200504090358.38088.jon@ffconsultancy.com> X-Miltered: at nez-perce with ID 425744C4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 eijiro:01 sumii:01 integers:01 haskell:01 ocaml:01 frog:98 wrote:01 exception:01 polymorphic:01 polymorphic:01 define:01 functions:01 tuples:01 caml:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Wednesday 06 April 2005 16:15, Eijiro Sumii wrote: > So here it goes: why don't we have polymorphic +, -, etc. while we > have polymorphic =, <, etc.? Many novices and (at least) some experts > feel that +., -., etc. are not quite nice. Why not define +, -, > etc. for as many types as possible such as integers, floating-point > numbers, and tuples? I think they can be implemented almost in the > same efficient way as =. They can also raise an exception if applied > to unsupported values such as functions, just as = does. I'm just curious, but what would you have expected the result of: # (1, 2, 3) * (2, 3, 4);; to be? i.e. an inner product, element-wise multiplication or an outer product? > P.S. I believe I'm not proposing anything as serious as Haskell type > classes. Oh, this isn't serious? ;-) > If so, I can perhaps restate my question as: why is the line drawn between = > and + now? I would say that polymorphic comparisons are useful in many more circumstances than polymorphic arithmetics would be, so their inclusion is justified. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists