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 AAA09991; Sun, 18 Nov 2001 00:18:00 +0100 (MET) 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 AAA09920 for ; Sun, 18 Nov 2001 00:17:59 +0100 (MET) Received: from staff.cs.usyd.edu.au (staff.cs.usyd.edu.au [129.78.8.1]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id fAHNHu924183 for ; Sun, 18 Nov 2001 00:17:57 +0100 (MET) Received: from hons.cs.usyd.edu.au. by staff.cs.usyd.edu.au.; Sun, 18 Nov 2001 10:17:51 +1100 Received: from localhost (mrak@localhost) by hons.cs.usyd.edu.au (8.9.3/8.9.3) with ESMTP id KAA06176; Sun, 18 Nov 2001 10:17:51 +1100 X-Authentication-Warning: hons.cs.usyd.edu.au: mrak owned process doing -bs Date: Sun, 18 Nov 2001 10:17:51 +1100 (EST) From: Mark Wotton To: Clemens Hintze cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: [Q]: Co(ntra)variance and subtyping? In-Reply-To: <20011117185051.A7607@qiao.in-berlin.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 17 Nov 2001, Clemens Hintze wrote: > - Covariance means that a specialized class also specialize the > arguments of overloaded methods. You use 'narrow' instead of > 'specializing' ... > - Contravariance, however, is generalizing arguments of overloaded > methods in specialized classes. > > So in this light, your example should demonstrate covariance, isn't > it? But what I do not like in the explanation above, is that it also > only refer to OOP and not types. You're quite right. I had it the wrong way around. Too little sleep... > Another explanation I've found, was (a --> b means a subtypes b): > > - Covariance means, that if t' --> t ==> t' list --> t list With this relationship, you would expect that "t' list" would be able to do anything that "t list" could do, as it's a subtype: therefore, you'd expect to be able to add a t to the front. With covariance, you can't: it's expecting the more specialised type t'. > - Contravariance, however, if t' --> t ==> t list --> t' list This way, you can take "t list" and add either "t" or "t'" to the front. Therefore, "t list" can do anything that "t' list" can, and the intuitive notion of subtypes is preserved. Apologies for getting it wrong the first time. It's doubly embarrassing as it seems I made the same mistake in the thesis I just handed in... mrak ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr