Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Invalid_argument("equal: abstract value")?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-01-01 (13:36)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] Invalid_argument("equal: abstract value")?
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}


{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

-- Damien

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: