From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA24682; Sat, 14 Aug 2004 15:57:22 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 PAA24237 for ; Sat, 14 Aug 2004 15:57:21 +0200 (MET DST) Received: from annexia.force9.co.uk (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7EDvKmL009536 for ; Sat, 14 Aug 2004 15:57:20 +0200 Received: from rich by annexia.force9.co.uk with local (Exim 3.36 #1 (Debian)) id 1Bvz27-0005Tw-00 for ; Sat, 14 Aug 2004 14:57:19 +0100 Date: Sat, 14 Aug 2004 14:57:19 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] Infix operators Message-ID: <20040814135719.GA20950@annexia.org> References: <20040814225919.0bed9f65.ocaml-erikd@mega-nerd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040814225919.0bed9f65.ocaml-erikd@mega-nerd.com> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at nez-perce with ID 411E1A40.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 gcaml:01 furuse:01 generics:01 generic:01 gcaml:01 type-safe:01 ltd:98 compiler:01 ocaml:01 caml:01 caml:01 int:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, Aug 14, 2004 at 10:59:19PM +1000, Erik de Castro Lopo wrote: > Hi all, > > I've got a number of defined types for which I'd like to define > infix operators for addition, subtraction, multiplication etc. > > Unfortunately since each type needs is own infix operator I'm > running out of ideas unique operator versions for each type. > > Why is it not possible to do something like: > > let ( ++ ) (a:float) (b:float) = a +. b ;; > > let ( ++ ) (a:int) (b:int) = a + b ;; > > which with the full type specification should allow the compiler > to figure out which version to use in a given situation. GCaml can do this: http://pauillac.inria.fr/~furuse/generics/ # generic plus = | int -> int -> int => (+) | float -> float -> float => (+.) ;; (Actually, I'm not sure whether or not it can do the infix ops part). What is the status of GCaml w.r.t it becoming a part of standard OCaml? Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment MOD_CAML lets you run type-safe Objective CAML programs inside the Apache webserver. http://www.merjis.com/developers/mod_caml/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners