From: Brian Hurt <brian.hurt@qlogic.com>
To: <brogoff@speakeasy.net>
Cc: Brian Hurt <brian.hurt@qlogic.com>,
David Monniaux <David.Monniaux@ens.fr>,
hermanns <jan_hermanns@gmx.de>,
"caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Why are arithmetic functions not polymorph?
Date: Fri, 23 May 2003 16:15:35 -0500 (CDT) [thread overview]
Message-ID: <Pine.LNX.4.33.0305231552520.2037-100000@eagle.ancor.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0305231309330.25081-100000@grace.speakeasy.net>
On Fri, 23 May 2003 brogoff@speakeasy.net wrote:
> I understand the difference between operator redefinition, which OCaml and
> SML have, and user defined overloading, which neither has, but which can be
> found in Haskell and Clean (sort of, through type classes) and C++ and Ada.
>
> I actually think overloading can be *really* *really* good. The problem, or
> rather, one of the many problems, with C++ IMO is that it has overloading and
> implicit conversions of types. That's a bad combination.
>
> One nice thing about GCaml is that it shouldn't bother people like you who
> dislike overloading. The overloading is fairly explicit and closed world.
> It gracefully handles the most important, very simple cases, and sneaks
> in the ability to type a much wider range of functions than can be typed now.
> You should at least take a look at the README in the prototype to get an idea of
> what I mean here.
OK. I'm reading the readme. First off, congratulations, you're dodging a
lot of the bullets that C++ didn't.
Here's a question. Consider the following code:
generic one = | int => 1 | float => 1.0
generic two = | int => 2 | float => 2.0
generic plus = | int -> int -> int = (+)
| float -> float -> float = (+.)
plus one two;;
What's the result? Is it the int 3, or the float 3.0?
Another problem already arises with the generic (aka overloaded)
comparisons- you oftentimes need to arbitrarily specify types in order to
replace the expensive call to the generic compare with a much cheaper
inlined type-specific compare. If you start having to specify types a lot
more often, that reduces the advantage of having type inference.
> New operators are not sufficient, and SML is more powerful in it's ability to
> define new operators than OCaml (minus CamlP4) is.
Yeah- I'd like to be able to define accessor operators somehow. Say being
able to define $[ ] as hashtbl lookups, so that h$[3] ==> Hashtbl.find h
3.
Brian
-------------------
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
next prev parent reply other threads:[~2003-05-23 21:01 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
2003-05-23 20:25 ` brogoff
2003-05-23 21:15 ` Brian Hurt [this message]
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=Pine.LNX.4.33.0305231552520.2037-100000@eagle.ancor.com \
--to=brian.hurt@qlogic.com \
--cc=David.Monniaux@ens.fr \
--cc=brogoff@speakeasy.net \
--cc=caml-list@inria.fr \
--cc=jan_hermanns@gmx.de \
/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