* [Caml-list] Nested classes and types @ 2002-01-09 16:50 Boris Yakobowski 2002-01-09 18:02 ` Jeremy Fincher 2002-01-09 18:25 ` Remi VANICAT 0 siblings, 2 replies; 3+ messages in thread From: Boris Yakobowski @ 2002-01-09 16:50 UTC (permalink / raw) To: caml-list 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 ? Thank you for hour help. Boris Yakobowski ------------------- 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Nested classes and types 2002-01-09 16:50 [Caml-list] Nested classes and types Boris Yakobowski @ 2002-01-09 18:02 ` Jeremy Fincher 2002-01-09 18:25 ` Remi VANICAT 1 sibling, 0 replies; 3+ messages in thread From: Jeremy Fincher @ 2002-01-09 18:02 UTC (permalink / raw) To: Boris Yakobowski; +Cc: caml-list You have to use the "parameterization trick" since syntax doesn't work. > Example : > > class type c_foo = > object > val val_foo : t_foo > end > and > t_foo = Foo of c_foo type 'a _t_foo = Foo of 'a class type c_foo = object val val_foo : c_foo _t_foo end type t_foo = c_foo _t_foo That'll get you a type t_foo that does what you want. Jeremy ------------------- 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Nested classes and types 2002-01-09 16:50 [Caml-list] Nested classes and types Boris Yakobowski 2002-01-09 18:02 ` Jeremy Fincher @ 2002-01-09 18:25 ` Remi VANICAT 1 sibling, 0 replies; 3+ messages in thread From: Remi VANICAT @ 2002-01-09 18:25 UTC (permalink / raw) To: caml-list "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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-01-09 18:28 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-01-09 16:50 [Caml-list] Nested classes and types Boris Yakobowski 2002-01-09 18:02 ` Jeremy Fincher 2002-01-09 18:25 ` Remi VANICAT
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox