Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] exceptions and the polymorphic equality
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: eijiro_sumii@a...
Subject: Re: [Caml-list] exceptions and the polymorphic equality
> On the other hand, the structural equality (=) when applied to
> exceptions and constructors is not completely specified, hence
> unreliable. 

I see, this makes sense - indeed, exn is not an equality type in SML.

> You're right, having e <> e' should be desirable. However, in this
> case you should not test structural equality, since it is very likely
> the case that e and e' are represented by the same kind of value. You
> should test identity (==) instead:
> 
> # e == e';;
> - : bool = false
> 
> That's what the compiler generates when pattern matching exception
> values (more precisely it uses == for the exception constructor and
> regular pattern matching for the rest of the pattern).

Several people have suggested using == instead of =, but doing so
seems even more problematic because:

        Objective Caml version 3.01

# exception Foo;;
exception Foo
# Foo == Foo;;
- : bool = false
# 

Regards,

	Eijiro
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr