[m-rev.] for discussion: subtypes documentation

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Nov 26 00:42:56 AEDT 2002


On 25-Nov-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Can we include a definition of covariance and contravariance here?  I
> can't remember what they mean and ten minutes of web trawling has left
> me none the wiser.

Covariance means that means that they vary together; that is, the
argument type for a subtype can be a subtype of the base type's argument type
(and it cannot be a supertype of the base type's argument type).

Contravariance means that they vary oppositely: that is, the the argument
type for a subtype must be a supertype of the base type's argument type.

Invariance (in this context) means that the argument type for a subtype
must be exactly the same as the argument type for the base type.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list