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
Type abstraction and (polymorphic) equality
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-06-29 (09:45)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] Type abstraction and (polymorphic) equality

Christophe TROESTLER writes:
 > The problem was that the attached information (an additional field in
 > a record) was a cyclic data structure.  From there on, all equality
 > tests became deadly!
 > ...
I fully agree. I bumped into this  issue a few months ago and helped a
friend of mine to discover the same issue no later than yesterday!

It is actually not really difficult to identify this issue: first, the
Out_of_memory  is raised very  quickly; second,  there is  an explicit
message when  the Gc verbose mode  is activated; finally,  it is quite
easy to find it with the  debugger (one "run" and then one "back" will
tell  you  that  the   Out_of_memory  is  raised  during  a  structual
comparison). But that's not the point.

I have no  good solution to propose,  but it would be nice  if we were
not allowed  to apply structural  comparison on abstract  (or private)
datatypes.  Then  you  would  have  to  export  an  explicit  equality
function, and even  if you are going  to define it as (=)  most of the
time, you would have to think about it at least one second.

But I agree that it is quite difficult to incorporate this in the type