From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: sumii@saul.cis.upenn.edu
Cc: caml-list@inria.fr
Subject: Re: polymorphic equality and overloading
Date: Tue, 04 Jul 2000 16:09:00 +0900 [thread overview]
Message-ID: <20000704160900Z.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: Your message of "Fri, 30 Jun 2000 13:51:05 -0400" <20000630135105Q.sumii@saul.cis.upenn.edu>
> > Equality really is overloaded, but since overloading isn't easily
> > integrated into ML style type systems, some other solution is chosen.
>
> So, I'm wondering why equality is overloaded in Caml, unlike addition
> (+ for integers, +. for floats, ^ for strings, etc.) for example. Or,
> why is equality automatically defined for tuples and datatypes, while
> addition isn't? Is that just because it is often useful?
The answer is in your sentence: how do you define addition on tuples ?
Or even on strings: ^ is not addition but concatenation;
fun s1 s2 -> string_of_float (float_of_string s1 +. float_of_string s2)
will give you a very different result.
The only form of overloading currently accepted in Caml is universal
overloading, that is operations available at all types.
Comparison is just "naturally" defined on almost anything, the only
exceptions being function closures which have no identity, and C data
when no custom operation is defined.
There is some arbitrary part in this definition, but even so
being able to compare values is useful anyway (Set and Map modules).
I do not really see what would be the use of an underspecified
addition on algebraic datatypes, for instance.
If you want other candidates for universal overloading, print would be a
better choice. Theoretically all values can be printed in a way or
another, and there may be uses for that. However this requires much
more runtime type information.
Regards,
---------------------------------------------------------------------------
Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp
<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>
next prev parent reply other threads:[~2000-07-05 21:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-29 21:10 Eijiro Sumii
2000-06-30 17:08 ` Brian Rogoff
2000-06-30 17:51 ` Eijiro Sumii
2000-07-04 7:09 ` Jacques Garrigue [this message]
2000-07-04 12:42 ` Eijiro Sumii
2000-07-05 1:11 ` Jacques Garrigue
2000-07-05 2:37 ` Eijiro Sumii
2000-07-05 21:22 ` Pierre Weis
2000-07-05 21:30 ` Eijiro Sumii
2000-07-05 22:15 ` Pierre Weis
2000-07-05 23:09 ` Eijiro Sumii
2000-07-06 17:18 ` Benjamin Werner
2000-07-05 22:40 John R Harrison
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=20000704160900Z.garrigue@kurims.kyoto-u.ac.jp \
--to=garrigue@kurims.kyoto-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=sumii@saul.cis.upenn.edu \
/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