From: Eijiro Sumii <eijiro_sumii@anet.ne.jp>
To: caml-list@inria.fr
Cc: sumii@saul.cis.upenn.edu
Subject: Re: [Caml-list] ambitious proposal: polymorphic arithmetics
Date: Wed, 06 Apr 2005 16:31:44 -0400 (EDT) [thread overview]
Message-ID: <20050406.163144.51837136.eijiro_sumii@anet.ne.jp> (raw)
In-Reply-To: <20050406.151450.98562588.eijiro_sumii@anet.ne.jp>
P.S.
> From: "Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl>
> | + can't be treated in the same way, because it won't distinguish
> | whether it's called as 1 + 1 or true + true. If it returns 2 in the
> | former case, it would produce a nonsensical bool value in the latter
> | case.
> |
> | OCaml doesn't have a mechanism for making +, - applicable to a limited
> | set of types and for dispatching their implementation based on the type
> | rather than on the physical representation.
>
> This is an excellent point. (Somebody else also pointed it out in a
> reply to me.)
Since this seems to be the most serious issue, I checked what could
happen in slightly greater detail.
----------------------------------------------------------------------
Objective Caml version 3.08.2
# let c = (Obj.magic (Obj.magic true + Obj.magic true) : bool) ;;
val c : bool = <unknown constructor>
# if c then 123 else 456 ;;
- : int = 123
# type t = A | B ;;
type t = A | B
# let d = (Obj.magic (Obj.magic B + Obj.magic B) : t) ;;
val d : t = <unknown constructor>
# (function A -> 78 | B -> 90) d ;;
- : int = 90
#
----------------------------------------------------------------------
So, it indeed leads to "unknown" values and behaviors, but doesn't
seem to break memory safety (in this case, at least). This may or may
not be regarded as something similar to the "undefined" (or only
partially specified) behavior of Pervasives.compare for function
values.
Or are there actually other cases where even memory safety can be
broken?
Eijiro
next prev parent reply other threads:[~2005-04-06 20:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-06 15:15 Eijiro Sumii
2005-04-06 15:51 ` [Caml-list] " Sébastien Hinderer
2005-04-06 15:56 ` Richard Jones
2005-04-06 16:43 ` Dmitry Lomov
2005-04-06 18:59 ` Richard Jones
2005-04-06 19:19 ` Jacques Carette
2005-04-07 0:01 ` Ethan Aubin
2005-04-06 16:39 ` [Caml-list] " William Lovas
2005-04-06 16:59 ` Andreas Rossberg
2005-04-06 18:50 ` Eijiro Sumii
2005-04-06 19:33 ` Eijiro Sumii
2005-04-07 0:13 ` William Lovas
2005-04-07 1:58 ` Jacques Garrigue
2005-04-06 17:00 ` Christophe TROESTLER
2005-04-06 19:20 ` Eijiro Sumii
2005-04-07 14:00 ` Christophe TROESTLER
2005-04-06 17:23 ` Marcin 'Qrczak' Kowalczyk
2005-04-06 18:01 ` padiolea
2005-04-06 19:14 ` Eijiro Sumii
2005-04-06 20:31 ` Eijiro Sumii [this message]
2005-04-06 21:53 ` Marcin 'Qrczak' Kowalczyk
2005-04-06 22:38 ` Eijiro Sumii
2005-04-06 19:23 ` Richard Jones
2005-04-09 2:58 ` Jon Harrop
2005-04-09 3:16 ` Eijiro Sumii
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=20050406.163144.51837136.eijiro_sumii@anet.ne.jp \
--to=eijiro_sumii@anet.ne.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