polymorphism: overloading vs. overriding

Markus Kranz markus_kranz at gmx.net
Sun May 7 15:58:30 PDT 2006


Uh, I didn't know the issue of "covariance versus contravariance" is a topic of
continuing debate:

http://c2.com/cgi/wiki?ContraVsCoVariance

and especially

http://www.cs.trinity.edu/~mlewis/CSCI3294-F01/Papers/p431-castagna.pdf

where I found on page 10:

"At this point, we are able to make precise the roles played
by covariance and contravariance in subtyping: contravariance 
is the correct rule when you want to substitute a function 
of a given type for another one of a different type; 
covariance is the correct condition when you want to specialize 
(in object-oriented jargon "override") a branch of an overloaded 
function by one with a smaller input type."

Regards,
Markus





More information about the Digitalmars-d mailing list