协变与逆变:对旧问题的新审视(面向学习函数式编程者的高级类型系统入门)
Covariance and Controvariance: a fresh look at an old issue (a primer in advanced type systems for learning functional programmers)
AI总结:
本文重新审视协变与逆变方法参数特化问题,以通俗示例向本科生和函数式编程者解释高级类型理论,并揭示编译器实现中鲜为人知的高级技术。
摘要:
二十年前,在一篇题为“协变与逆变:无因之冲突”的文章中,我曾论证面向对象编程中方法参数的协变特化与逆变特化具有不同目的,并推断它们不仅能够、而且实际上应当共存于同一语言中。在本文中,我结合(子)类型理论与编程语言领域的最新进展,重新审视该文章的结果,对这一旧问题采取全新的视角。实际上,重新讨论此问题仅为撰写一篇论文的借口,该论文旨在以简单术语和示例,向计算机科学本科生及/或有意向的函数式编程者解释复杂的类型理论概念。最后,我借此机会描述了一些未见于文献的类型系统实现高级技术,这些技术仅为少数深入钻研某些编译器代码的内部人士所知:因此,即使是专家级语言设计者与实现者,也可能发现本文值得一读。
英文摘要:
Twenty years ago, in an article titled "Covariance and contravariance: conflict without a cause", I argued that covariant and contravariant specialization of method parameters in object-oriented programming had different purposes and deduced that, not only they could, but actually they should both coexist in the same language. In this work I reexamine the result of that article in the light of recent advances in (sub-)typing theory and programming languages, taking a fresh look at this old issue. Actually, the revamping of this problem is just an excuse for writing an essay that aims at explaining sophisticated type-theoretic concepts, in simple terms and by examples, to undergraduate computer science students and/or willing functional programmers. Finally, I took advantage of this opportunity to describe some undocumented advanced techniques of type-systems implementation that are known only to few insiders that dug in the code of some compilers: therefore, even expert language designers and implementers may find this work worth of reading.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。