Taming the wildcards

Author:

Altidor John1,Huang Shan Shan2,Smaragdakis Yannis1

Affiliation:

1. University of Massachusetts, Amherst, Amherst, MA, USA

2. LogicBlox Inc., Atlanta, GA, USA

Abstract

Variance allows the safe integration of parametric and subtype polymorphism. Two flavors of variance, definition-site versus use-site variance, have been studied and have had their merits hotly debated. Definition-site variance (as in Scala and C#) offers simple type-instantiation rules, but causes fractured definitions of naturally invariant classes; Use-site variance (as in Java) offers simplicity in class definitions, yet complex type-instantiation rules that elude most programmers. We present a unifying framework for reasoning about variance. Our framework is quite simple and entirely denotational, that is, it evokes directly the definition of variance with a small core calculus that does not depend on specific type systems. This general framework can have multiple applications to combine the best of both worlds: for instance, it can be used to add use-site variance annotations to the Scala type system. We show one such application in detail: we extend the Java type system with a mechanism that modularly infers the definition-site variance of type parameters, while allowing use-site variance annotations on any type-instantiation. Applying our technique to six Java generic libraries (including the Java core library) shows that 20-58 (depending on the library) of generic definitions are inferred to have single-variance; 8-63% of method signatures can be relaxed through this inference, and up to 91% of existing wildcard annotations are unnecessary and can be elided.

Publisher

Association for Computing Machinery (ACM)

Subject

Computer Graphics and Computer-Aided Design,Software

Reference24 articles.

1. J. Altidor S. S. Huang and Y. Smaragdakis. Taming the wildcards: Combining definition- and use-site variance (extended version). http://www.cs.umass.edu/ yannis/variance-extended2011.pdf. J. Altidor S. S. Huang and Y. Smaragdakis. Taming the wildcards: Combining definition- and use-site variance (extended version). http://www.cs.umass.edu/ yannis/variance-extended2011.pdf.

2. A parallel object-oriented language with inheritance and subtyping

3. Apache Software Foundation. Apache commons-collections library. http://larvalabs.com/collections/. Version 4.01. Apache Software Foundation. Apache commons-collections library. http://larvalabs.com/collections/. Version 4.01.

4. J. Bloch. The closures controversy. http://www.javac.info/bloch-closures-controversy.ppt. Accessed Nov. 2010. J. Bloch. The closures controversy. http://www.javac.info/bloch-closures-controversy.ppt. Accessed Nov. 2010.

5. K. Boumillion and J. Levy. Guava: Google core libraries for Java 1.5 K. Boumillion and J. Levy. Guava: Google core libraries for Java 1.5

Cited by 2 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. Verifying Whiley Programs with Boogie;Journal of Automated Reasoning;2022-03-20

2. Precise static analysis for generic programs in object oriented languages;ACM SIGSOFT Software Engineering Notes;2012-05-16

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3