<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/50f653064d6e45748cb96c80bc084526"
  from="Oleg Trott &lt;oleg_trott@c...&gt;"
  author="Oleg Trott"
  date="2003-11-11T06:48:41"
  subject="Re: [Caml-list] Strange physical equality behavior"
  prev="2003/11/e506f6dcbfdcb3186798daea27c0bc18"
  next="2003/11/4ae1225ca603ad7ed2d2972c89a080a0"
  prev-in-thread="2003/11/fc1129f81c56884cc7eeba1ab3565fec"
  next-in-thread="2003/11/fcbf42708ad0d737e60ce7569d4ac60e"
  prev-thread="2003/11/c1e744886a3affa901d1dcaf0e350359"
  next-thread="2003/11/09e582c31663ff8716cce84f773350e2"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Strange physical equality behavior">
<msg 
  url="2003/11/01e1b29e39f68e928829da73207a8c30"
  from="Oleg Trott &lt;oleg_trott@c...&gt;"
  author="Oleg Trott"
  date="2003-11-09T18:34:28"
  subject="[Caml-list] Strange physical equality behavior">
<msg 
  url="2003/11/a33bcd6e98a9ec945c42f2e24c4f7045"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-11-10T01:33:39"
  subject="Re: [Caml-list] Strange physical equality behavior">
<msg 
  url="2003/11/a4fa114bc35fac9ad8b2bce95978fe86"
  from="Oleg Trott &lt;oleg_trott@c...&gt;"
  author="Oleg Trott"
  date="2003-11-10T02:25:58"
  subject="Re: [Caml-list] Strange physical equality behavior">
<msg 
  url="2003/11/9230ae0d897716b56921b56f5d31f9fe"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-11-10T08:29:32"
  subject="Re: [Caml-list] Strange physical equality behavior">
<msg 
  url="2003/11/31b3758dc01ba9496581b9fd7e7c1e48"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-11-10T18:41:57"
  subject="Re: [Caml-list] Strange physical equality behavior">
<msg 
  url="2003/11/fc1129f81c56884cc7eeba1ab3565fec"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-11-11T01:35:16"
  subject="Re: [Caml-list] Strange physical equality behavior">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/11/50f653064d6e45748cb96c80bc084526"
  from="Oleg Trott &lt;oleg_trott@c...&gt;"
  author="Oleg Trott"
  date="2003-11-11T06:48:41"
  subject="Re: [Caml-list] Strange physical equality behavior">
<msg 
  url="2003/11/fcbf42708ad0d737e60ce7569d4ac60e"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-11-11T16:47:13"
  subject="Re: [Caml-list] Strange physical equality behavior">
<msg 
  url="2003/11/a13ba4cc36c14e7d7021336bcbc04024"
  from="William Lovas &lt;wlovas@s...&gt;"
  author="William Lovas"
  date="2003-11-12T00:32:48"
  subject="Re: [Caml-list] Strange physical equality behavior">
</msg>
</msg>
<msg 
  url="2003/11/2fe7f757bc7b5d10efc2915878644160"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2003-11-11T17:08:25"
  subject="Re: [Caml-list] Strange physical equality behavior">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
On Sunday 09 November 2003 08:33 pm, Jacques Garrigue wrote:
&gt;  On mutable structures, [e1 == e2] is true if and only if
&gt;    physical modification of [e1] also affects [e2].

By the way, either "mutable structures" or "physical modification" need to be 
clarified, because if (int ref list) is "mutable" then the above is wrong:

 let a = [ref 0];;
 let b = ref 0 :: a;;
 incr (List.hd a);; (*  physical  ? *)
 a == b;;
 b;;

&gt; On non-mutable structures, the behavior of [(==)] is
&gt; implementation-dependent; however, it is guaranteed that
&gt; [e1 == e2] implies [e1 = e2].

This doesn't work for "nan" though, as was recently discussed. [1] 

&gt; The functorial approach offers a much cleaner solution.

I'm not convinced.

With non-functorial sets:

type t = Leaf of string | Node of t Set.t

How would you do this with functorial sets? Perhaps like this:

http://groups.google.com/groups?selm=fa.dlqsupe.1c6ajga%40ifi.uio.no

    module A : sig
                 type t = Leaf of string | Node of ASet.t
                 val compare: t -&gt; t -&gt; int
               end
             = struct
                 type t = Leaf of string | Node of ASet.t
                 let compare t1 t2 =
                   match (t1, t2) with
                     (Leaf s1, Leaf s2) -&gt; Pervasives.compare s1 s2
                   | (Leaf _, Node _) -&gt; 1
                   | (Node _, Leaf _) -&gt; -1
                   | (Node n1, Node n2) -&gt; ASet.compare n1 n2
               end
    and ASet : Set.S with type elt = A.t
             = Set.Make(A)

(BTW, that example doesn't yet work in 3.07-2 default toplevel. And couldn't 
one write "let compare = Pervasives.compare" above? )

&gt; I'm yet to see code mixing two sets of the same type but with different 
&gt; comparison functions.

Exactly! That's why *statically* assuring ordering function consistency is not 
all that important [2]. Which is why x==x would be a bigger help than 
recursive modules.

[1] I can understand false "nan = nan", because "nan" is a kind of exception, 
but false "x == x" feels very non-mathematical to me.

[2] I am a static typing fan, but this seems excessive.

Regards,
Oleg

P.S. I've already participated in this discussion longer than my tolerance for 
language-lawyerism or passion about this issue allow me, so I'll probably end 
it here.
-- 
Oleg Trott &lt;oleg_trott@columbia.edu&gt;

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

</contents>

</message>

