caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <damien.doligez@inria.fr>
To: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Invalid_argument("equal: abstract value")?
Date: Thu, 1 Jan 2004 14:36:49 +0100	[thread overview]
Message-ID: <8D358CE2-3C5F-11D8-BEFF-00039310CAE8@inria.fr> (raw)
In-Reply-To: <1072926610.4197.81.camel@pelican>

On Thursday, January 1, 2004, at 04:10 AM, skaller wrote:

> A bigint is (well, at least contains) an abstract
> primitive defined in C, not an algebraic data type.
> The compiler doesn't know how to compare bigints.

This is only half the story.

> This could be fixed the same way as for finalisers ..
> provide a table of hooks for custom blocks.
> Another candidate other than comparison is obviously
> serialisation to extend Marshal for abstract/opaque types.

We already have a hook for comparison (and serialisation) in
custom blocks.

We don't want to use it for the type "nat" for the following
reason.  "nat"s are used in "big_int"s and "ratio"s, which are
numeric types, but without canonical representation.  For example,
the rational number 3 can be represented by:

{numerator = {sign = 1; abs_value = 3}
  denominator = {sign = 1; abs_value = 1}
  normalized = true}

or

{numerator = {sign = 1; abs_value = 6}
  denominator = {sign = 1; abs_value = 2}
  normalized = false}

If we use the hook for comparison on nat, and your program
tries to compare these two numbers, then the generic equality
function will return "not equal", which is the wrong result.  We
think it's better to stop the program than to let the bug go
unnoticed.

-- Damien

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


      reply	other threads:[~2004-01-01 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-31 21:55 Tom Hawkins
2003-12-31 22:21 ` Tom Hawkins
2004-01-01  3:10   ` skaller
2004-01-01 13:36     ` Damien Doligez [this message]

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=8D358CE2-3C5F-11D8-BEFF-00039310CAE8@inria.fr \
    --to=damien.doligez@inria.fr \
    --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).