From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA25624 for caml-redistribution; Sun, 7 Jun 1998 00:02:17 +0200 (MET DST) 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 HAA32339 for ; Fri, 5 Jun 1998 07:46:29 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id HAA16607 for ; Fri, 5 Jun 1998 07:46:25 +0200 (MET DST) Received: from localhost (safran.kurims.kyoto-u.ac.jp [130.54.16.91]) by kurims.kurims.kyoto-u.ac.jp (8.8.8/3.6W) with ESMTP id OAA03939; Fri, 5 Jun 1998 14:46:06 +0900 (JST) To: tews@tcs.inf.tu-dresden.de Cc: caml-list@inria.fr Subject: Re: co(ntra)-variant subtyping In-Reply-To: Your message of "Thu, 4 Jun 1998 17:17:40 +0200" <199806041517.RAA00640@ithif18.inf.tu-dresden.de> References: <199806041517.RAA00640@ithif18.inf.tu-dresden.de> X-Mailer: Mew version 1.92 on Emacs 20.2 / Mule 3.0 (MOMIJINOGA) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <19980605144558K.garrigue@kurims.kyoto-u.ac.jp> Date: Fri, 05 Jun 1998 14:45:58 +0900 From: Jacques GARRIGUE X-Dispatcher: imput version 971024 Sender: weis From: Hendrik Tews > Didier Remy asked me for examples where the missing subtype rule > for Adt's is a problem ... > 1. Assume you have windows, which allow you to ask for their > children: [..] > Now transient_window is not a subtype of window. Probably not a very good example: I do not see here why children of a transient window shall also be transient windows... > 2. You can implement an automaton by modeling the states as > objects : > > class automaton : 'a = > ... > method successor_state : 'a option > end > > Again it is not possible to built a subtype of an automaton. Better. There is still a way around, by raising an exception rather than returning None, but agreedly this would not be very nice. > This is actually more than I asked. For my application if would > suffice if subtyping rules exist only for non-abstract types ie. > variant and record types. There is no new syntax necessary for > this, only a variance checker. And this variance checker is included in O'Labl. So your examples would work. > We did not want to add yet another notion in the language, and therefore > we prefered to make all non-primitive type constructors non variant. > > I see. And what about an optional variance syntax, just for those > how want covariant lists? This is a possibility. In fact I proposed such a syntax to Didier a while ago. It would be needed only for abstract types, and one might also ommit it when not interested in a type's variance: since most O'Caml libraries are anyway compiled from source, you can always add this information later if you need it. However, I shall add that for me, the true problem with subtyping under constructors is the complexity of the subtyping algorithm. The current algorithm can easily explode, and subtyping under constructors makes it even easier. So the real question might be: is it reasonable to have the typability of a program depend on its size ? Jacques --------------------------------------------------------------------------- Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp JG