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
Re: circular types?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-10-26 (14:48)
From: Hendrik Tews <tews@t...>
Subject: Re: circular types?

John Max Skaller writes:
   From: John Max Skaller <>
   Date: Thu, 26 Oct 2000 01:03:29 +1100
   Subject: Re: circular types?
   I think this can be done now. Here is the method: to have a type t
   and a class c mutually dependent, for example:
   	class type c = object x : t end
   	and type  t = C c | Null
   	class type c' ['t] = object x : 't end
   	type t = C t c' | Null
   	class type c = t c'

Yes, this is the theoretical answer. But this just doesn't work
out in anything bigger than a tutorial example. I am involved in
programming a logic compiler. We have about 40 variant types and
at least 10 classes. If my design were not constraint by the
abilities of the ocaml compiler some of the classes were in
mutual recursion with the bigger halve of the variant types. So
you are not telling me seriously I should write classes with 10
type variables!

Just for curiosity: Does somebody use the above workaround in a
project with more than 10.000 lines of ocaml code? (We do, but
every typing error is a nightmare.)