Browse thread
Weird behavior with mutually recursive type definitions
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jerome Vouillon <Jerome.Vouillon@i...> |
| Subject: | Re: Weird behavior with mutually recursive type definitions |
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