English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: ocamlyacc and polymorphic variants
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-01-11 (17:31)
From: Markus Mottl <mottl@m...>
Subject: Re: ocamlyacc and polymorphic variants
> The internal representation does only depend on the name of the
> constructor. This is described in one of Jacques Garrigues papers
> about Olabl. In particular you find, that variant tags `C00J10
> and `N60r0 have the same internal representation, so you can't
> use both of them in one program. (This was at least the case
> olabl 2.02, I haven't checked it with ocaml 2.99.)

Thanks for the explanation - now this really helps in understanding how the
internal representation looks like. I have just tried this with OCaml 2.99
- here the result:

  # `C00J10 = `N60r0;;
  In this program, variant constructors `C00J10 and `N60r0
  have same hash value.

Interesting: so the internal representation of tags for polymorphic
variants is just the hash value of their names! Luckily, the system seems
to check whether two different names accidently have the same hash value...
(though it is probably very unlikely that two hash values of "normal" names

I guess that this is always safe since all the polymorphic variants appear
in the type, which makes it always unambiguous how to interpret values.

Best regards,
Markus Mottl

Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl