* type and class definition : recursion
@ 1996-05-14 12:11 pbrisset
1996-05-14 20:04 ` Christian Boos
0 siblings, 1 reply; 2+ messages in thread
From: pbrisset @ 1996-05-14 12:11 UTC (permalink / raw)
To: caml-list; +Cc: pbrisset
Hello,
I would like to define a class and a type with a mutual recursion between
them. Something like
type t = A
| B of c
and class c (x:t) =
val mutable value = x
end
Is it possible with O'caml ?
--------------
Pascal Brisset
ENAC, 7 avenue Edouard Belin, BP 4005, F-31055 Toulouse Cedex, France
Tel: +33 62 17 40 53, E-mail: pbrisset@eis.enac.dgac.fr, Fax: +33 62 17 41 43
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: type and class definition : recursion
1996-05-14 12:11 type and class definition : recursion pbrisset
@ 1996-05-14 20:04 ` Christian Boos
0 siblings, 0 replies; 2+ messages in thread
From: Christian Boos @ 1996-05-14 20:04 UTC (permalink / raw)
To: pbrisset; +Cc: caml-list
pbrisset@eis.enac.dgac.fr writes:
> I would like to define a class and a type with a mutual recursion between
> them. Something like
>
> type t = A
> | B of c
> and class c (x:t) =
> val mutable value = x
> end
>
> Is it possible with O'caml ?
>
> --------------
Yes :
#type 'a t = A | B of 'a;;
type 'a t = A | B of 'a
#class c (x : 'a t) : 'a = val mutable value = x end;;
class c ('a t) : 'a =
val mutable value : 'a t
end
#let foo = new c A;;
val foo : c = <obj>
#let bar = new c (B foo);;
val bar : c = <obj>
#
-- Christian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-05-15 8:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-05-14 12:11 type and class definition : recursion pbrisset
1996-05-14 20:04 ` Christian Boos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox