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 UAA25127; Fri, 23 May 2003 20:12:38 +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 UAA25567 for ; Fri, 23 May 2003 20:12:37 +0200 (MET DST) Received: from swordfish ([216.241.35.41]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h4NICaH19244 for ; Fri, 23 May 2003 20:12:36 +0200 (MET DST) Received: from matt by swordfish with local (Exim 3.35 #1 (Debian)) id 19JH1w-0002NE-00 for ; Fri, 23 May 2003 12:12:36 -0600 Date: Fri, 23 May 2003 12:12:36 -0600 From: Matt Gushee To: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] Why are arithmetic functions not polymorph? Message-ID: <20030523181236.GE3246@swordfish> Reply-To: Matt Gushee Mail-Followup-To: caml-list@pauillac.inria.fr References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.27i X-Spam: no; 0.00; gushee:01 mgushee:01 havenrock:01 caml-list:01 brogoff:01 abominable:01 flamefest:01 python:01 implemented:01 real-world:01 englewood:01 manure:01 ignores:01 --lao:01 merel:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, May 23, 2003 at 01:02:33PM -0500, Brian Hurt wrote: > On Fri, 23 May 2003 brogoff@speakeasy.net wrote: > > > > SML has a kind of operator overloading, but I don't know the details. > > > > SML doesn't allow the user to define overloadings, and that is an > > abomination. Java is similarly abominable. > > > > Ocaml allows you to define *new* operators to your heart's content. You > just can't overload the meanings of old operators. And frankly, I don't > find that abominable at all. I don't want to turn this into a C++ > flamefest (had one of those already this week), but in my experience > operator overloading is *really* *really* bad. Hmm, you may be right. Much of my programming experience is with Python, where operators applied to objects are implemented as instance methods, and can be overloaded to your heart's content. For example: class FunnyMoney: def __init__(self): self.balance = 0 def __sub__(self, other): self.balance = self.balance + other # BWAHAHAHAAA! myaccount = FunnyMoney() myaccount.balance ==> 0 myaccount - 12000000 myaccount.balance ==> 12000000 Of course, you can have a lot of fun with this feature. But it may be a rather bad idea for real-world applications. -- Matt Gushee When a nation follows the Way, Englewood, Colorado, USA Horses bear manure through mgushee@havenrock.com its fields; http://www.havenrock.com/ When a nation ignores the Way, Horses bear soldiers through its streets. --Lao Tzu (Peter Merel, trans.) ------------------- 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