caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matt Gushee <mgushee@havenrock.com>
To: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] Why are arithmetic functions not polymorph?
Date: Fri, 23 May 2003 12:12:36 -0600	[thread overview]
Message-ID: <20030523181236.GE3246@swordfish> (raw)
In-Reply-To: <Pine.LNX.4.33.0305231259070.2037-100000@eagle.ancor.com>

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


  reply	other threads:[~2003-05-23 18:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-22 22:31 hermanns
2003-05-22 23:10 ` Brian Hurt
2003-05-23  1:34 ` Nicolas Cannasse
2003-05-23  9:56 ` David Monniaux
2003-05-23 10:13   ` Ville-Pertti Keinonen
2003-05-23 16:34   ` brogoff
2003-05-23 18:02     ` Brian Hurt
2003-05-23 18:12       ` Matt Gushee [this message]
2003-05-23 20:25       ` brogoff
2003-05-23 21:15         ` Brian Hurt
2003-05-23 21:23           ` brogoff
2003-06-03  3:42         ` John Max Skaller
2003-06-03  4:10           ` Oleg Trott
2003-06-03  6:57             ` John Max Skaller
2003-06-03  3:25       ` John Max Skaller
2003-06-06  7:08         ` easy print and read (was: [Caml-list] Why are arithmetic functions not polymorph?) Oleg Trott
2003-06-06 10:46           ` Pierre Weis
2003-06-06 16:40             ` brogoff
2003-06-07 10:59               ` Stefano Zacchiroli
2003-06-07 14:44               ` Jun.Furuse
2003-06-08  6:32                 ` brogoff
2003-06-08  8:49             ` Chris Hecker
2003-06-09  9:40               ` Jun.Furuse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030523181236.GE3246@swordfish \
    --to=mgushee@havenrock.com \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).