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 CAA20214 for caml-redistribution; Tue, 15 Jun 1999 02:29:02 +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 XAA26346 for ; Mon, 14 Jun 1999 23:30:22 +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 XAA12717; Mon, 14 Jun 1999 23:30:19 +0200 (MET DST) Received: (from vouillon@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA22997; Mon, 14 Jun 1999 23:30:19 +0200 (MET DST) Message-ID: <19990614233019.41897@pauillac.inria.fr> Date: Mon, 14 Jun 1999 23:30:19 +0200 From: Jerome Vouillon To: Hendrik Tews , caml-list@inria.fr Subject: Re: grammar for class types, reraised References: <199906140804.KAA01028@ithif20.inf.tu-dresden.de> 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: <199906140804.KAA01028@ithif20.inf.tu-dresden.de>; from Hendrik Tews on Mon, Jun 14, 1999 at 10:04:32AM +0200 Sender: weis On Mon, Jun 14, 1999 at 10:04:32AM +0200, Hendrik Tews wrote: > 1. What is the difference between > > # class type b = [int, string] a;; > > and > > # type c = (int, string) a;; > > assuming some class type a with two type parameters? The former expression also defines a class type and a type #c. > And why do I have to use different parentheses in both cases? > (Yes, I know, it's what the manual says, but I would expect that > one kind of parentheses should be enough for all kind of type > parameters. ) It was not possible to use regular parentheses for class parameters, as the grammar would have been too hard to parse. Consider for example : class d = (a b : t) class d = (a b) d On the other hand, it was not acceptable to change the grammar of types. That's why there are two different kind of parenthesis. > 2. Why is it not possible to add type constraints to the first > kind of type abbreviation, like in > > class type ['a] c = ['a, string] a constraint 'a = int;; There is no real reason. I think I could add this quite easily to the language if you need this. > 3. (To re-raise a question from John Prevost which has never been > addressed:) Why is it not possible to mix type definitions and > class type definitions like in > > # class type a = object method m : a end > # and > # type b = Node of a | Tree of b * b > > (Yes, it is possible to use the < ... > notation, but it is not > possible to use # with such types.) 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 -- Jérôme