English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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-25 (19:10)
From: John Max Skaller <skaller@o...>
Subject: Re: circular types?
Brian Rogoff wrote:

> And if you can do that then allowing mutual recursion between
> classes and types also should be allowed.

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'

and you have it. In other words, abstract out the types from
the classes by making them type parameters, declare the types,
using appropriately instantiated class types, and then name the
required class instances.

As far as I can see, this always works, and thus shows
(constructively) that mutual recursion between classes and types
can be supported. 

John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net