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 D6D04BB91 for ; Sun, 9 Jan 2005 14:19:29 +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 j09DJTi0007236 for ; Sun, 9 Jan 2005 14:19:29 +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 OAA14028 for ; Sun, 9 Jan 2005 14:19:28 +0100 (MET) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id j09DJScR007230 for ; Sun, 9 Jan 2005 14:19:28 +0100 Received: (qmail invoked by alias); 09 Jan 2005 13:19:28 -0000 Received: from p3E9E177F.dip.t-dialin.net (EHLO p3E9E177F.dip.t-dialin.net) (62.158.23.127) by mail.gmx.net (mp026) with SMTP; 09 Jan 2005 14:19:28 +0100 X-Authenticated: #470194 Received: from nico by p3E9E177F.dip.t-dialin.net with local (Exim 3.35 #1 (Debian)) id 1Cncyf-0000ZC-00 for ; Sun, 09 Jan 2005 14:19:29 +0100 Date: Sun, 9 Jan 2005 14:19:29 +0100 From: wiedergaenger@fastmail.fm To: caml-list@inria.fr Subject: generic functions Message-ID: <20050109131928.GA1759@wafthrudnir> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i Sender: Helgi Sohn des Sigmund Toeter des Hunding X-Y-GMX-Trusted: 0 X-Miltered: at nez-perce with ID 41E12F61.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41E12F60.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 clos:01 ocaml:01 foo:01 foo:01 redefined:01 pointless:01 functions:01 functions:01 lisp:01 lisp:01 int:01 argument:01 objects:02 objects:02 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.2 required=5.0 tests=NO_REAL_NAME autolearn=disabled version=3.0.0 X-Spam-Level: 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: let foo (x : int) = x*x;; let foo (x : float) = x*.x;; 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.