caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Max Skaller <skaller@ozemail.com.au>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Why are arithmetic functions not polymorph?
Date: Tue, 03 Jun 2003 13:42:41 +1000	[thread overview]
Message-ID: <3EDC1931.80307@ozemail.com.au> (raw)
In-Reply-To: <Pine.LNX.4.44.0305231309330.25081-100000@grace.speakeasy.net>

brogoff@speakeasy.net wrote:

> 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. 

In Felix I took the opposite approach. First, overloading
requires an exact match, and there are no implicit conversions,
so it's fairly easy to decide which overload with a closed
type is selected.

Second, unlike C++, and totally opposite to GCaml,
functions are looked up by (name,signature) which means
a function with the wrong signature doesn't hide
one further up scope. In C++ the overload
set is always in the same scope, since lookup is by name,
then tries for a match. (This tends to force all templates and 
overloadable entities into the top level scope).
GCaml requires you to package
up all the overloads in one place. So you might say:

	GCaml - explicitly constructed closed world
	C++ - implicitly constructed partially closed
	Felix - implicitly constructed fully open

Third, Felix follows the C++ rules for matching
polymorphic overloads. Matches on explicit type arguments
are done by counting the number of arguments.
For implicit arguments, all candidates whose signatures
unify with the call signature are collected, and then
the most specific one (if unique) is chosen (even if there
is a closer more general overload).

The open-ness of the Felix model does make for some
degree of fragility compared to the much more robust
GCaml model, however the GCaml technique is considerably
more verbose, and brevity and easy of naming is one of
the arguments in favour of overloading.

-- 
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850


-------------------
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


  parent reply	other threads:[~2003-06-03  3:42 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
2003-05-23 21:23           ` brogoff
2003-06-03  3:42         ` John Max Skaller [this message]
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=3EDC1931.80307@ozemail.com.au \
    --to=skaller@ozemail.com.au \
    --cc=caml-list@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).