From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA28689; Thu, 1 Jan 2004 14:36:48 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA28082 for ; Thu, 1 Jan 2004 14:36:47 +0100 (MET) Received: from inria.fr (planar.net0.nerim.net [213.41.168.102]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id i01Dakv21705 for ; Thu, 1 Jan 2004 14:36:46 +0100 (MET) Date: Thu, 1 Jan 2004 14:36:49 +0100 Subject: Re: [Caml-list] Invalid_argument("equal: abstract value")? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v553) From: Damien Doligez To: caml-list Content-Transfer-Encoding: 7bit In-Reply-To: <1072926610.4197.81.camel@pelican> Message-Id: <8D358CE2-3C5F-11D8-BEFF-00039310CAE8@inria.fr> X-Mailer: Apple Mail (2.553) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 damien:01 damien:01 bigint:01 bigints:01 finalisers:01 hooks:01 opaque:01 nat:01 nat:01 numerator:01 normalized:01 numerator:01 normalized:01 generic:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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