From: "Sébastien Furic" <sebastien.furic@tni-software.com>
To: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Are you sure the new "=" of 3.08 is good ?
Date: Fri, 08 Oct 2004 09:37:44 +0000 [thread overview]
Message-ID: <41665FE8.8030208@tni-software.com> (raw)
In-Reply-To: <4165B1A5.9040208@univ-savoie.fr>
Christophe Raffalli wrote:
>
> I spend one complete day to adapt Phox (my theorem prover) to 3.08
> because the new = does not check first physical equality. Hopefully, the
> backtracking ocamldebugger let me pin point the many "=" which were
> looping, otherwise I would have spend a month !!!
>
> I was assuming two things about equal:
> - scan of block from left to right
> - a test on adress equality on pointer before follwing the pointer
> (which is now wrong in 3.08).
>
> Then in a data type with some structure starting with an identifier
> filed like
>
> type symbol = structh { id : int; ... },
>
> if you have the property that two structures with the same id are always
> physically equal, the old "=" would never scan the structure itself.
IMHO it is often better to define your own equality predicates because
"=" has another annoying property : it fails when comparing "external"
objects and this failure happens only when comparison reaches those
objects (note that the type system is perfectly happy, even in the
presence of "external" objects). For instance, imagine one of the fields
of a record you want to compare is a Big_int : your program will fail
only if "=" can't decide for inequality before reaching those fields.
Objective Caml version 3.08.1
# #load "nums.cma";;
# type test = { n: Num.num };;
type test = { n : Num.num; }
# { n = Num.num_of_string"10000000000000000000000000000000" } = { n =
Num.num_of_string "200000000000000000000000000000000" };;
Exception: Invalid_argument "equal: abstract value".
I discovered this behavior when I was developping libraries to handle
DAGs for a symbolic manipulation program written in OCaml (using the Num
library). All the preliminary tests of the libraries were OK (I only
used "internal" objects) but the day I had to use them I had a great
surprise : they were not as "generic" as I believed them to be.
In conclusion, if you want your modules to be truly generic, never
use "polymorphic" equality.
Cheers,
Sébastien.
-------------------
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:[~2004-10-08 8:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-07 21:14 Christophe Raffalli
2004-10-08 7:38 ` Jean-Christophe Filliatre
2004-10-08 8:31 ` Christophe Raffalli
2004-10-08 15:10 ` Damien Doligez
2004-10-08 9:37 ` Sébastien Furic [this message]
2004-10-08 15:54 ` Xavier Leroy
2004-10-08 2:54 Harrison, John R
2004-10-08 5:49 ` Christophe Raffalli
2004-10-08 6:54 ` David Brown
2004-10-08 16:25 Harrison, John R
2004-10-08 16:35 Harrison, John R
2004-10-08 17:34 ` Damien Doligez
2004-10-09 8:58 ` Xavier Leroy
2004-10-09 17:56 Harrison, John R
2004-10-09 18:10 Harrison, John R
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=41665FE8.8030208@tni-software.com \
--to=sebastien.furic@tni-software.com \
--cc=caml-list@inria.fr \
--cc=christophe.raffalli@univ-savoie.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