Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Nested classes and types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi VANICAT <vanicat@l...>
Subject: Re: [Caml-list] Nested classes and types
"Boris Yakobowski" <Boris.Yakobowski@ens-lyon.fr> writes:

> I need to declare two types depending one on the other ; one of them is
> a class type, with a menber variable of the second type, and the other
> one is a basic type with a constructor needing an argument of the first
> type.
> 
> Example :
> 
>   class type c_foo =
>   object
>     val val_foo : t_foo
>   end
> and
>   t_foo = Foo of c_foo
> 
> However, that syntax doesn't work ; is there a correct one ?

not exactly, but there is a workaround :



class type ['a] c_foo1 =
object
  val val_foo : 'a
end

type t_foo = Foo of (t_foo c_foo1)

class type c_foo =
object
   inherit [t_foo] c_foo1
end


-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
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