Version française
Home     About     Download     Resources     Contact us    
Browse thread
A nastier example
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eric Cooper <ecc@c...>
Subject: Re: [Caml-list] A nastier example
On Sat, May 14, 2005 at 04:51:07PM +0200, Julien Verlaguet wrote:
> Here is a nastier case than the one in the previous msg.
> 
> exception E of int;;
> 
> let x=E(1);;
> 
> exception E of bool;;
> 
> x=E(true);;
> 
> answer : true
> 
> I received many mails (in private), explaining to me how the equality 
> works in OCaml, how exceptions are represented etc ...
> Which is not what I was asking, I will try to reformulate :
> 
> Is this the behaviour we want ?
> 
> Can two values of different types be equal ?

But these aren't different types -- they're both type "exn".
For example:
    let test e = (e = Exit)
    val test : exn -> bool = <fun>
So test can be applied to any exception, no matter what kind of
structure it has.

-- 
Eric Cooper             e c c @ c m u . e d u