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
[Caml-list] Recursive classes and subtyping
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-02-01 (13:42)
From: Frederic Tronel <Frederic.Tronel@i...>
Subject: Re: [Caml-list] Recursive classes and subtyping
> In the first case, the type "a" is not fully known when the coercion
> "(c :> a)" is performed, as the classes are mutually recursive.  The
> compiler handles this case as if it knew nothing about the structure
> of the type "a".  With this assumption, the only case the compiler can
> be sure that the type of "c" is a subtype of "a" is when the type of
> "c" is "a".  This is not the case, hence the error message.
> The reason for this overly conservative (in this case) assumption is
> that the result of the type inference algorithm could otherwise depend
> on the order in which the program is typed.

Clear !

> If you really need mutually recursive classes, a work-around is to
> explicitely define the classe types before defining the classes.

I don't really need recursive classes, but I started
writing my classes in a top-down manner with forward references to
to be defined. Hence, the use of recursive classes. I can simply change
my definitions order (bottow-up), it solves the problem !


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