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 NAA18748 for caml-redistribution; Wed, 28 Jan 1998 13:56:28 +0100 (MET) 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 QAA04737 for ; Mon, 26 Jan 1998 16:40:27 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.5) with ESMTP id QAA07014; Mon, 26 Jan 1998 16:40:23 +0100 (MET) Received: (from remy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA04729; Mon, 26 Jan 1998 16:40:23 +0100 (MET) Message-Id: <199801261540.QAA04729@pauillac.inria.fr> Subject: Re: polymorphic methods in O'Caml (fwd) In-Reply-To: from David Monniaux at "Jan 22, 98 06:57:10 pm" To: monniaux@clipper.ens.fr (David Monniaux) Date: Mon, 26 Jan 1998 16:40:23 +0100 (MET) Cc: caml-list@inria.fr From: Didier.Remy@inria.fr (Didier Remy) Reply-to: Didier.Remy@inria.fr Organization: INRIA, BP 105, F-78153 Le Chesnay Cedex Phone: (33) 1 3963 5317 -- Sec: (33) 1 3963 5570 -- Fax: (33) 1 3963 5684 Web: http://pauillac.inria.fr/~remy MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: weis > [ J'aimerais des methodes polymorphes dans le systeme d'objets. ] C'est possible, mais cela reste a implementer. > The problem I have is the following: I have methods that can be invoked on > container widgets to add a widget into them. As methods can be > polymorphic, and more specifically can't have a parameter of type > #someclass, use of those methods has to include a cast onto the type > "widget". This is inelegant (watch for the (xxx :> widget) expressions in > the sample code included). We are aware of this problem. This is one of the (several) reasons that motivated our investigation of first-class polymophism in ML [1]. Here, we show that there is no theoretical problem at all. Technically, this requires to trace some form of type sharing analogous to the one used for object type aliases in O'Caml. In practive, it would provide polymorphic methods in O'Caml in a quite simple way. > Therefore, I'd like polymorphic methods to be implemented (even if it > needs some explicit type declaration). To get a polymophic method you would need to explicitly give its (polymorphic) type in the class where it is defined. Types of objects with polymophic methods would be inferred, but you would also be required to explicitly write them when the context would not provide sufficient type constraints, This would not affect at all classes or objects that only use monomorphic methods. > Is there any reason why this couldn't be done? We should certainly add this feature in some future version of O'Caml, but nothing has been done yet. --Didier. [1] Extending ML with Semi-Explicit Higher-Order Polymorphism. Jacques Garrigue and Didier Rémy. In International Symposium on Theoretical Aspects of Computer Software, volume 1281 of Lecture Notes in Computer Science, pages 20--46. Springer, September 1997. URL http://pauillac.inria.fr/~remy/publications.html