Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Mutual recursion between classes and types in OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Anton Lavrik <asl@t...>
Subject: [Caml-list] Mutual recursion between classes and types in OCaml


I suppose it's quite useful to define object types and "ordinary" types, so
that they could refer to each other. For example,

	class c = 
	object val v = A 0	(* constructor `A' is not bound *)

	[...] (* some syntactic construct like `and' keyword *)

	type t = A of int | B of c (* now type `t' and constructor `A' are
	defined *)
It is possible to mix these two type definition forms in sequential order.
And AFAIK it's not possible to define types like in the example above,
at least in direct manner (however one can use polymorphic classes and
virtualization to achieve analogous results, but this is very
inconvenient in general).

So why mutual recursion between classes and types is not allowed? Is this
fundamental or technical problem? I can't find any references denoting that

BTW, what does `-rectypes' ocamlc's option really mean (there are quite a
few words about it in reference manual)? And how does it concern the

Regards, Anton.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: