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 VAA01625; Sat, 14 Aug 2004 21:04:16 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 VAA00915 for ; Sat, 14 Aug 2004 21:04:15 +0200 (MET DST) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i7EJ4DRM001925 for ; Sat, 14 Aug 2004 21:04:14 +0200 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1Bw3p5-0006ns-00 for ; Sat, 14 Aug 2004 21:04:13 +0200 Received: from panic.cs.bris.ac.uk ([137.222.103.158]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 14 Aug 2004 21:04:11 +0200 Received: from brown by panic.cs.bris.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 14 Aug 2004 21:04:11 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Julian Brown Subject: [Caml-list] Re: Infix operators Date: Sat, 14 Aug 2004 19:04:09 +0000 (UTC) Organization: University of Bristol Message-ID: References: <20040814225919.0bed9f65.ocaml-erikd@mega-nerd.com> Reply-To: brown@cs.bris.ac.uk X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: panic.cs.bris.ac.uk User-Agent: slrn/0.9.8.0 (Linux) X-Miltered: at concorde with ID 411E622D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; 2004:99 rubbish:01 wrote:03 suppose:03 infix:03 infix:03 types:03 12.:95 let:04 let:04 somewhere:04 define:05 define:05 breaks:06 suggestion:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 2004-08-14, 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. I came up with a totally rubbish solution to this: define an "infix-ising" operator like so which lets you use "long" operator names made of plain characters: let (%) a b = b a let add a b = a + b let addf a b = a +. b 5 %add 6 10. %addf 12. This is not a serious suggestion though, since it totally breaks under lots of situations, mostly involving precedence. Still, I suppose there might be a use for it somewhere. Julian ------------------- 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