From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6E645BB91 for ; Sun, 9 Jan 2005 15:56:41 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j09Eueib012878 for ; Sun, 9 Jan 2005 15:56:41 +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 PAA16575 for ; Sun, 9 Jan 2005 15:56:40 +0100 (MET) Received: from furbychan.cocan.org (use.the.admin.shell.to.set.your.reverse.dns.for.this.ip [80.68.91.176] (may be forged)) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j09Eue1Z012874 for ; Sun, 9 Jan 2005 15:56:40 +0100 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1CneUd-00021k-00; Sun, 09 Jan 2005 14:56:35 +0000 Date: Sun, 9 Jan 2005 14:56:32 +0000 To: wiedergaenger@fastmail.fm Cc: caml-list@inria.fr Subject: Re: [Caml-list] generic functions Message-ID: <20050109145629.GA6290@furbychan.cocan.org> References: <20050109131928.GA1759@wafthrudnir> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20050109131928.GA1759@wafthrudnir> User-Agent: Mutt/1.3.28i From: Richard Jones X-Miltered: at concorde with ID 41E14629.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41E14628.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 ocaml:01 clos:01 ocaml:01 foo:01 foo:01 redefined:01 pointless:01 furuse:01 generics:01 functions:01 functions:01 lisp:01 lisp: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: On Sun, Jan 09, 2005 at 02:19:29PM +0100, wiedergaenger@fastmail.fm wrote: > I just got from LISP to OCaml, and wondered if there is an equivalent of > generic functions from LISP (CLOS) in OCaml. In the Common Lisp Object > System methods don't belong to certain objects/classes. They are just > function specializing on the argument types. So basically I want to > write something like: >=20 > let foo (x : int) =3D x*x;; > let foo (x : float) =3D x*.x;; >=20 > This, obviously, will not work since foo is just redefined by the second > statement. One would think, that having methods not being belonging to > objects/classes, is rather pointless. Well 95% of the time, there is no > necessity for that. But in the other 5%, it is really helpful.=20 The general solution is GCaml (http://pauillac.inria.fr/~furuse/generics/README.gcaml) which is not part of OCaml core. Rich. --=20