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 42D8DBB91 for ; Mon, 10 Jan 2005 11:47:20 +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 j0AAlJoY027052 for ; Mon, 10 Jan 2005 11:47:19 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA18117 for ; Mon, 10 Jan 2005 11:47:19 +0100 (MET) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0AAlJQ9016107 for ; Mon, 10 Jan 2005 11:47:19 +0100 Received: from localhost (akasha.ijm.jussieu.fr [134.157.173.57]) by shiva.jussieu.fr (8.12.11/jtpda-5.4) with ESMTP id j0AAlIa6043722 ; Mon, 10 Jan 2005 11:47:18 +0100 (CET) X-Ids: 164 Date: Mon, 10 Jan 2005 11:47:16 +0100 (CET) Message-Id: <20050110.114716.71093554.andrieu@ijm.jussieu.fr> To: alex@barettadeit.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] generic functions From: Olivier Andrieu In-Reply-To: <41E25116.1010805@barettadeit.com> References: <41E25116.1010805@barettadeit.com> X-Mailer: Mew version 4.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.7.2 (shiva.jussieu.fr [134.157.0.164]); Mon, 10 Jan 2005 11:47:18 +0100 (CET) X-Miltered: at nez-perce with ID 41E25D37.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41E25D37.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at shiva.jussieu.fr with ID 41E25D36.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Antivirus: scanned by sophie at shiva.jussieu.fr X-Spam: no; 0.00; caml-list:01 andrieu:01 andrieu:01 ijm:01 baretta:01 foo:01 foo:01 rec:01 jussieu:01 functions:01 poly:01 poly:01 int:01 int:01 match:02 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Alex Baretta [Mon, 10 Jan 2005]: > 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 Hum, I would have written this in that way : ,---- | let foo_int (`Int x) = `Int (x * x) | let foo_float (`Float x) = `Float (x *. x) | | let foo = function | | #poly_int as x -> foo_int x | | #poly_float as x -> foo_float x `---- What's the use for the `other -> foo other' clauses ? -- Olivier