Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Claudio Sacerdoti Coen <sacerdot@c...>
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.
>... 
> If you really need mutually recursive classes, a work-around is to
> explicitely define the classe types before defining the classes.

 I suppose this should be related with this other example
 (which is the semplification of a problem I have just met):

# type -'a t;;
type -'a t
# class c (obj : [> `A] t) = object end
  and d (obj : [`A] t) = object method c = new c obj end;;
class c : [ `A] t -> object end
class d : [ `A] t -> object method c : c end

 Is there any way to to obtain the type "class c : [> `A] t -> object end"
 while keeping the mutual recursion?

 I have tried to explicitely define the class types, but I have had no
 success at all.

				Thanks in advance,
                                     C.S.C.

-- 
----------------------------------------------------------------
Real name: Claudio Sacerdoti Coen
PhD Student in Computer Science at University of Bologna
E-mail: sacerdot@cs.unibo.it
http://caristudenti.cs.unibo.it/~sacerdot
----------------------------------------------------------------
-------------------
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