From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 01761BB91 for ; Mon, 10 Jan 2005 10:55:37 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0A9ta0M020083 for ; Mon, 10 Jan 2005 10:55:36 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA16461 for ; Mon, 10 Jan 2005 10:55:36 +0100 (MET) Received: from alex.barettalocal.com (h213-255-109-130.albacom.net [213.255.109.130] (may be forged)) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j0A9tZZ0020072 for ; Mon, 10 Jan 2005 10:55:35 +0100 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by alex.barettalocal.com (Postfix) with ESMTP id 1D1252BB16F; Mon, 10 Jan 2005 10:55:35 +0100 (CET) Message-ID: <41E25116.1010805@barettadeit.com> Date: Mon, 10 Jan 2005 10:55:34 +0100 From: Alex Baretta User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5 X-Accept-Language: it, en-us, en MIME-Version: 1.0 To: Ocaml , Paolo Donadeo Subject: Re: [Caml-list] generic functions References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41E25118.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41E25117.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 caml-list:01 wrote:01 wrote:01 foo:01 foo:01 overloading:01 overloading:01 caml's:01 inference:01 recursive:01 compiler:01 toplevel:01 unification:01 extensional:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: Brian Hurt wrote: > On Sun, 9 Jan 2005 wiedergaenger@fastmail.fm wrote: > >>let foo (x : int) = x*x;; >>let foo (x : float) = x*.x;; >> > With the exception of certain artificial contests (Paul Graham) I've never > met a real world problem that needed overloading, or even benefitted > signifigantly from overloading that didn't benefit just as much or more > from one of the solutions above. > > Brian As a member of the International Caml's Jihad, I'd like to spend two cents of dynamite on this topic: type inference is as good as honey in large scale industrial projects, where sometimes the typing of complex recursive polymorphic algorithms is not evident until you get the printout from the compiler or the toplevel. Thank you, O great Unification Algorithm. But, then again, extensional polymorphism is also a much needed feature. In my company we depend heavily on on extensional polymorphism to create exstensibile functions. We have implemented this on top of explicitly polymorphic types: i.e. polymorphic variant types. Let us all faithfully await the Coming of the the Gcaml... And meanwhile let us use polymorphic variants to get the same effect. type poly_int = [ `Int of int ] type poly_float = [ `Float of float ] let foo_int foo = function | `Int x -> `Int(x * x) | other -> foo other let foo_float foo = function | `Float x -> `Float(x *. x) | other -> foo other let rec foo x = match x with | #poly_int -> foo_int foo x | #poly_float -> foo_float foo x All hail Ocaml! Alex, after too many nights spent writing typechecking code... -- ********************************************************************* http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. +39 02 370 111 55 fax. +39 02 370 111 54 Our technology: The Application System/Xcaml (AS/Xcaml) The FreerP Project