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
OO programming
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-03-03 (10:20)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] OO programming
From: "Tiphaine.Turpin" <Tiphaine.Turpin@free.fr>

> I don't know if there is an equivalent to inherit for 
> polymorphic variants: "type t' = private  [> t | ...] doesn't seem to 
> work. And using objects to encode variants is possible, but you may be 
> used to more serious solutions...

It's actually simple with polymorphic variants than with objects.
You just write
    type t' = private [> t ]
but t has to be a non-private polymorphic variant type.
So you have to maintain a hierarchy of non-private types, to be
able to build your private types. This should be already apparent in
my code for event.