Browse thread
Representation of different polymorphic variants guaranteed to be different?
-
Bruno Daniel
-
Eric Cooper
- Elnatan Reisner
- Bruno Daniel
- Frédéric_van_der_Plancke
-
Eric Cooper
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Frédéric_van_der_Plancke <fvdp@d...> |
| Subject: | Re: [Caml-list] Representation of different polymorphic variants guaranteed to be different? |
Eric Cooper wrote: > On Wed, Jul 08, 2009 at 08:35:27PM +0200, Bruno Daniel wrote: > >> How is it ensured that I get a <> b for a and b created as >> polymorphic variants from two different identifiers? Will pattern >> matching give wrong results if I accidentally choose two different >> identifiers translated to the same internal representation? >> > > See this thread: > http://caml.inria.fr/pub/ml-archives/caml-list/2005/03/544288096a47d82ec870d01c8396f5fe.fr.html > > Short answer: collisions could theoretically occur, but are detected > at link time. > > Actually at compile time, as stated by Jacques Garrigue* *in the last message of said thread: "By the way, the check is not at link time, as was stated in another message, but at compile time. It is the typing of variants itself that guarantees that no such conflict will go undetected. So you will be warned early enough." Example: # type a = [ `ABC | `zyctRecABC ];; Variant tags `ABC and `zyctRecABC have same hash value. Change one of them. Frédéric.