On 7/29/2009 3:25 AM, Elnatan Reisner wrote:
Is there something that can complete this analogy:
(=) is to (==) as Pervasives.compare is to ___?
That is, is there a polymorphic total ordering with respect to *physical*
entities, rather than to their structure?
Not really. The physical location of heap values is not stable (because
of the GC), so you cannot use it as a total ordering.
It may be useful to know that the generic structural comparison has a
physical behavior for OCaml objects (it compares their unique ids). So
wrapping your values inside objects can be a good trick to get physical
comparison (and hashing), as in:
class ['a] physical_reference init = object
val mutable current : 'a = init
method get = current
method set x = current <- x
end
-- Alain
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs