Re: grammar for class types, reraised

From: John Prevost (prevost@zarya.maya.com)
Date: Tue Jun 15 1999 - 19:04:17 MET DST


To: Jerome Vouillon <Jerome.Vouillon@inria.fr>
Subject: Re: grammar for class types, reraised
From: John Prevost <prevost@zarya.maya.com>
Date: 15 Jun 1999 13:04:17 -0400
In-Reply-To: Jerome Vouillon's message of "Mon, 14 Jun 1999 23:30:19 +0200"

Jerome Vouillon <Jerome.Vouillon@inria.fr> writes:

> This would probably be possible, but it is not trivial. And then, you
> would probably expect to be able to include in the recursion other
> construct, such as value definitions (for instance, if a function
> using the type b is used by the class a). This would make the
> implementation even more complicated.
>
> On the other hand, you can get rid of the mutual recursion by adding a
> type parameter to one of the type. For instance, you can change
> class type a = object method m : b end
> and
> type b = Node of a | Tree of b * b
> into
> type 'a b = Node of 'a | Tree of b * b
> class type a = object method m : a b end

My situation was somewhat more obscene, and would've required this:

type ('foo,'bar,'baz,'qux,'blatz,'zuttle,'potz,...) cast =
 | Foo of 'foo
 | Bar of 'bar
 | ...

class type node = object method downcast : (foo,bar,...) cast end
and bar = object ... end
...

The whole point of the excercise was to have a downcast method for a
set of specific classes, in a type-safe way. I eventually wrote code
using < ... > for all of the types.

John.



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:23 MET