3 ms·
Covariance and Contravariance: a fresh look at an old issue [pdf]
- muraiki 11y agoSummary: The author reexamines his assertion that covariance and contravariance can coexist through recent advances in (sub-)typing theory by "explaining sophisticated type theoretic concepts, in simple terms and by examples, to undergraduate computer science students and/or willing functional programmers". Meaning that he chooses to explain using code rather than theorems. Interesting, the author chose to demonstrate the examples using Perl 6, not because he is necessarily a fan of the language, but as he explains: "I chose it because it has the double advantage of having enough syntax to explain the covariance/contravariance problem and of having a fuzzy-yet-to-be-fixed type system... one of the challenges of this paper was to use a mainstream language that was not designed with types in mind — far from that —, whence the choice of Perl 6. I am aware that this choice will make some collegue researchers sneer and some practitioners groan: please give me the benefit of the doubt..." I suppose that "mainstream" means "more mainstream than CDuce" or other more esoteric research languages. :) Note that the paper assumes that you don't know Perl6, and it seems to only really use multimethods and objects -- nothing too crazy. Edit: This beginning parts of this paper probably also serve as a decent intro to strongly typed languages for those who only have used a dynamic language.