From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA26253 for caml-redistribution; Mon, 30 Aug 1999 10:05:07 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA14125 for ; Fri, 27 Aug 1999 12:13:42 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id MAA25055; Fri, 27 Aug 1999 12:12:55 +0200 (MET DST) Received: (from vouillon@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA16430; Fri, 27 Aug 1999 12:12:54 +0200 (MET DST) Message-ID: <19990827121254.36255@pauillac.inria.fr> Date: Fri, 27 Aug 1999 12:12:54 +0200 From: Jerome Vouillon To: Jacques GARRIGUE , Francois.Pottier@inria.fr Cc: caml-list@inria.fr Subject: Re: Weird behavior with mutually recursive type definitions References: <19990804155239.50895@pauillac.inria.fr> <19990813104206X.garrigue@kurims.kyoto-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mutt 0.89.1 In-Reply-To: <19990813104206X.garrigue@kurims.kyoto-u.ac.jp>; from Jacques GARRIGUE on Fri, Aug 13, 1999 at 10:42:06AM +0900 Sender: weis On Fri, Aug 13, 1999 at 10:42:06AM +0900, Jacques GARRIGUE wrote: > I personnaly think that, like for polymorphic recursion, the semantics > could be changed so that the user has to write explicitely the > constraints. In type definitions, this makes sense. If a constraint > appears to be needed somewhere and was not declared, there would be an > error. Technically this would probably mean doing two passes on type > definitions: one to introduce definitions (polymorphically) and one to > check the constraints. In such a way, one could avoid this strange > side-effect of the object system on the rest of the language. > > Comments, Jerome ? This would indeed be much less confusing. It is not clear to me how this can be done, though. An alternative would be that the compiler automatically sorts the type definitions so as to eliminate as much mutual recursion as possible. Then, all correct type abbreviations could be defined using mutually recursive type definitions and the user would not have to reorder manually the definitions. Type representations are already typed after the type abbreviations have been computed, which explains why the following definition is accepted: type 'a t = 'a and u = A of int t and v = B of bool t;; -- Jérôme