From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA32116; Sun, 29 Apr 2001 12:22:22 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 MAA32233 for ; Sun, 29 Apr 2001 12:22:20 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f3TAMIP00957 for ; Sun, 29 Apr 2001 12:22:19 +0200 (MET DST) Received: from localhost (isdnppp2.kurims.kyoto-u.ac.jp [130.54.16.103]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id TAA04880; Sun, 29 Apr 2001 19:22:06 +0900 (JST) To: pfitzen@informatik.uni-tuebingen.de Cc: caml-list@inria.fr Subject: Re: [Caml-list] co/contra-variance and class ? In-Reply-To: <200104271851.UAA03530@sunglasses.informatik.uni-tuebingen.de> References: <200104271851.UAA03530@sunglasses.informatik.uni-tuebingen.de> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20010429192451J.garrigue@kurims.kyoto-u.ac.jp> Date: Sun, 29 Apr 2001 19:24:51 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Juergen Pfitzenmaier > It is nice to see the introduction of explicit co/contra-variance > into ocaml. I just read the manual and didn't try some code, but > my understanding is that the variance stuff is only for type definitions > and not for classes. Why is this so ? Variance can be a mighty > tool in dealing with class hierarchies. Actually variance annotations are also allowed for type parameters in classes. I just forgot to add this to the reference manual. To be more precise: explicit variance annotations are only useful on abstract types. In all other cases covariance and contravariance of type parameters is automatically computed. So the question is rather: why can you write variance annotations on concrete types also. At the beginning, this was just a syntax problem: you cannot simultaneously allow annotations for abstract types and refuse them in other cases. Then it appeared that they could be useful to check the variance of a type parameter: since the compiler only shows the variance of type parameters for abstract types, in other cases writing it by hand will make sure that the parameters have at least the variance expected (but they can be stronger). Cheers, Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr