caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Bug in equality testing?
@ 1994-03-20 15:24 John Harrison
  1994-03-21 16:36 ` Vale'rie Me'nissier-Morain
  1994-03-21 23:46 ` Xavier Leroy
  0 siblings, 2 replies; 3+ messages in thread
From: John Harrison @ 1994-03-20 15:24 UTC (permalink / raw)
  To: caml-list; +Cc: John.Harrison


Hi,

I've come across the following, which unless I am being stupid
looks like a bug. The program below produces (in 0.6):

  true; true; false

John.

P.S. Thanks for the interesting replies on hash-consing. I'm afraid
I am likely to be pestering you with more questions about CAML soon.
It's a great system!

**********************************************
type Example = Var of string            
             | App of string *  Example list;;

let DEST = 
  fun (App p) -> p 
    | (Var _) -> failwith "DEST";;
          
let a = DEST(App("X",([]: Example list)));;
let b = ("X",([]: Example list));;
 
fst(a) = fst(b);;
snd(a) = snd(b);;
a = b;; 
**********************************************




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Bug in equality testing?
  1994-03-20 15:24 Bug in equality testing? John Harrison
@ 1994-03-21 16:36 ` Vale'rie Me'nissier-Morain
  1994-03-21 23:46 ` Xavier Leroy
  1 sibling, 0 replies; 3+ messages in thread
From: Vale'rie Me'nissier-Morain @ 1994-03-21 16:36 UTC (permalink / raw)
  To: caml-list

It is a well-known bug of the compilation of Caml Light. In fact, the
variables a and b are internally represented as:

       ----- ---- ----                    ------ ---- ----               
      | App |    |    |        and       | Pair |    |    |
       ----- -/-- --\-                    ------ -/-- --\-
             /       \                           /       \
           "X"       []                        "X"       []

so the generic equality says these 3-tuples are not equal since their
headers are not the same!

Valerie Menissier-Morain




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug in equality testing?
  1994-03-20 15:24 Bug in equality testing? John Harrison
  1994-03-21 16:36 ` Vale'rie Me'nissier-Morain
@ 1994-03-21 23:46 ` Xavier Leroy
  1 sibling, 0 replies; 3+ messages in thread
From: Xavier Leroy @ 1994-03-21 23:46 UTC (permalink / raw)
  To: John Harrison; +Cc: caml-list

> I've come across the following, which unless I am being stupid
> looks like a bug.

Yes, this is described as bug (1) in the file KNOWN-BUGS in the 0.6
distribution.

A simple workaround is to change the definition of the DEST function:
instead of

 let DEST = 
   fun (App p) -> p 
     | (Var _) -> failwith "DEST";;

write

 let DEST = 
   fun (App(x,y)) -> (x,y)
     | (Var _) -> failwith "DEST";;

Regards,

- Xavier Leroy




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1994-03-22 10:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-03-20 15:24 Bug in equality testing? John Harrison
1994-03-21 16:36 ` Vale'rie Me'nissier-Morain
1994-03-21 23:46 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).