From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA24994; Tue, 4 Nov 2003 18:50:36 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA25607 for ; Tue, 4 Nov 2003 18:50:34 +0100 (MET) Received: from avalon.ens-lsh.fr (mailhost.ens-lsh.fr [193.51.131.2]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hA4HoY129815 for ; Tue, 4 Nov 2003 18:50:34 +0100 (MET) Received: from avalon.ens-lsh.fr (localhost [127.0.0.1]) by avalon.ens-lsh.fr (8.12.8/8.12.8) with ESMTP id hA4IoPY8017149 for ; Tue, 4 Nov 2003 18:50:25 GMT Received: from ens-notes1.ens-lsh.fr (ens-notes1.ens-lsh.fr [10.2.1.44]) by avalon.ens-lsh.fr (8.12.8/8.12.8) with ESMTP id hA4IoPUY017146 for ; Tue, 4 Nov 2003 18:50:25 GMT Received: from mostha ([10.3.20.31]) by ens-notes1.ens-lsh.fr (Lotus Domino Release 5.0.10) with SMTP id 2003110418503115:19422 ; Tue, 4 Nov 2003 18:50:31 +0100 Date: Tue, 4 Nov 2003 18:52:12 +0100 From: Damien To: caml-list@inria.fr Subject: Re: [Caml-list] Mutually recursive classes Message-Id: <20031104185212.7808ab96.Damien.Pous@ens-lyon.fr> In-Reply-To: <20031103174144.0299613CBAB@garonne.edcsm.jussieu.fr> References: <20031103174144.0299613CBAB@garonne.edcsm.jussieu.fr> Organization: mosthagloups X-Mailer: Sylpheed version 0.9.6claws (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 X-MIMETrack: Itemize by SMTP Server on ens-notes1/ENS-LSH(Release 5.0.10 |March 22, 2002) at 04/11/2003 18:50:31, Serialize by Router on ens-notes1/ENS-LSH(Release 5.0.10 |March 22, 2002) at 04/11/2003 18:50:32, Serialize complete at 04/11/2003 18:50:32 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Loop: caml-list@inria.fr X-Spam: no; 0.00; damien:01 damien:01 ens-lyon:01 caml-list:01 unifying:01 'self:01 inferred:01 jacques:01 garrigue's:01 recursion:01 disallowing:01 glue:01 unify:01 ocaml:01 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I could solve my problem by first defining two "open class type", and then unifying 'self with the parameter in two other class types : << class type ['a, 'b] a_ot = object constraint 'b = ('a, 'b) #b_ot method coerce: 'a method b: 'b end and ['a, 'b] b_ot = object constraint 'a = ('a, 'b) #a_ot method coerce: 'b method a: 'a end class type ['b] a_t = object ('s) inherit ['s, 'b] a_ot end class type ['a] b_t = object ('s) inherit ['a, 's] b_ot end >> It was the same kind of problem as the one discussed in the parameters of a class are generalized after its type has been inferred. thus, with << class type ['b] a = object ('sa) method coerce: 'sa method b: 'b constraint 'b = 'sa #b end and ['a] b = object ('sb) method coerce: 'sb method a: 'a constraint 'a = 'sb #a end >> ocaml tries to unify 'sa (resp. 'sb) and 'a (resp. 'b) which is impossible since this would close the self types I lack some OO theory knowledges to understand the Jacques Garrigue's distinction between "structural definition" and "definition by name" (could someone explain me or send me some useful links ?) but I think that recursion with distinct type parameters should be allowed in the case above (recursive class _types_), disallowing it seems to me like a boring syntactic restriction, since one can always : - duplicate and separate the class type definitions ; (a_ot, b_ot) - add parameters for forward type definitions ('a, 'b) - glue all these types together to find back the first ones (a_t, b_t) Does anyone know a case where this is not true ? (with class types) What kind of "fully-recursive" classes are meaningless (just curious) thanks, damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners