Variance and generalized constraints for C# generics

31Citations
Citations of this article
31Readers
Mendeley users who have this article in their library.
Get full text

Abstract

Generic types in C# behave invariantly with respect to sub-typing. We propose a system of type-safe variance for C# that supports the declaration of covariant and contravariant type parameters on generic types. To support more widespread application of variance we also generalize the existing constraint mechanism with arbitrary subtype assertions on classes and methods. This extension is useful even in the absence of variance, and subsumes equational constraints proposed for Generalized Algebraic Data Types (GADTs). We formalize the subtype relation in both declarative and syntax-directed style, and describe and prove the correctness of algorithms for constraint closure and subtyping. Finally, we formalize and prove a type safety theorem for a featherweight language with variant classes and generalized constraints. © Springer-Verlag Berlin Heidelberg 2006.

Cite

CITATION STYLE

APA

Emir, B., Kennedy, A., Russo, C., & Yu, D. (2006). Variance and generalized constraints for C# generics. In Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) (Vol. 4067 LNCS, pp. 279–303). Springer Verlag. https://doi.org/10.1007/11785477_18

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free