Abstract
The support for generic programming in modern object-oriented programming languages is awkward and lacks desirable expressive power. We introduce an expressive genericity mechanism that adds expressive power and strengthens static checking, while remaining lightweight and simple in common use cases. Like type classes and concepts, the mechanism allows existing types to model type constraints retroactively. For expressive power, we expose models as named constructs that can be defined and selected explicitly to witness constraints; in common uses of genericity, however, types implicitly witness constraints without additional programmer effort. Models are integrated into the object-oriented style, with features like model generics, model-dependent types, model enrichment, model multimethods, constraint entailment, model inheritance, and existential quantification further extending expressive power in an object-oriented setting. We introduce the new genericity features and show that common generic programming idioms, including current generic libraries, can be expressed more precisely and concisely. The static semantics of the mechanism and a proof of a key decidability property can be found in an associated technical report.
- O. Agesen, S. N. Freund, and J. C. Mitchell. Adding type parameterization to the Java language. In Proc. 12th OOPSLA, pages 49–65, 1997. Google Scholar
Digital Library
- A. V. Aho, J. E. Hopcroft, and J. Ullman. Data Structures and Algorithms. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1st edition, 1983. Google Scholar
Digital Library
- J. Aldrich. The power of interoperability: Why objects are inevitable. In Proc. ACM Int’l Symp. on New Ideas, New Paradigms, and Reflections on Programming & Software (Onward!), pages 101––116, 2013. Google Scholar
Digital Library
- M. H. Austern. Generic Programming and the STL: Using and Extending the C++ Standard Template Library. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1998. Google Scholar
Digital Library
- G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In Proc. 13th OOPSLA, Oct. 1998. Google Scholar
Digital Library
- K. B. Bruce, M. Odersky, and P. Wadler. A statically safe alternative to virtual types. In Proc. 12th European Conf. on Object-Oriented Programming, number 1445 in Lecture Notes in Computer Science, pages 523–549, July 1998. Google Scholar
Digital Library
- P. Canning, W. Cook, W. Hill, J. Mitchell, and W. Olthoff. F-bounded polymorphism for object-oriented programming. In Proc. Conf. on Functional Programming Languages and Computer Architecture, pages 273–280, 1989. Google Scholar
Digital Library
- R. Cartwright and G. L. Steele Jr. Compatible genericity with run-time types for the Java programming language. In Proc. 13th OOPSLA, pages 201–215, Oct. 1998. Google Scholar
Digital Library
- M. M. T. Chakravarty, G. Keller, S. Peyton-Jones, and S. Marlow. Associated types with class. In Proc. 32nd POPL, pages 1–13, 2005. Google Scholar
Digital Library
- C. Chambers. Object-oriented multi-methods in Cecil. In O. L. Madsen, editor, Proc. 20th European Conf. on Object-Oriented Programming, volume 615, pages 33–56, 1992. Google Scholar
Digital Library
- C. Clifton, G. T. Leavens, C. Chambers, and T. Millstein. MultiJava: Modular open classes and symmetric multiple dispatch for Java. In Proc. 15th OOPSLA, pages 130–145, 2000. Google Scholar
Digital Library
- M. Day, R. Gruber, B. Liskov, and A. C. Myers. Subtypes vs. where clauses: Constraining parametric polymorphism. In Proc. 10th OOPSLA, pages 156–168, Oct. 1995. ACM SIGPLAN Notices 30(10). Google Scholar
Digital Library
- D. Dreyer, R. Harper, M. M. T. Chakravarty, and G. Keller. Modular type classes. In Proc. 34th POPL, pages 63–70, 2007. Google Scholar
Digital Library
- B. Emir, A. Kennedy, C. Russo, and D. Yu. Variance and generalized constraints for C# generics. In Proc. 20th European Conf. on Object-Oriented Programming, pages 279–303, 2006. Google Scholar
Digital Library
- findbugs-release. Findbugs. http://findbugs.sourceforge.net/.Google Scholar
- R. Garcia, J. Jarvi, A. Lumsdaine, J. G. Siek, and J. Willcock. A comparative study of language support for generic programming. In Proc. 18th OOPSLA, pages 115–134, 2003. Google Scholar
Digital Library
- J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification. Addison Wesley, 3rd edition, 2005. ISBN 0321246780. Google Scholar
Digital Library
- B. Greenman, F. Muehlboeck, and R. Tate. Getting F-bounded polymorphism into shape. In PLDI, pages 89–99, 2014. Google Scholar
Digital Library
- D. Gregor, J. Järvi, J. Siek, B. Stroustrup, G. Dos Reis, and A. Lumsdaine. Concepts: Linguistic support for generic programming in C++. In Proc. 21st OOPSLA, pages 291–310, 2006. Google Scholar
Digital Library
- A. Igarashi, B. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems, 23(3):396–450, 2001. Google Scholar
Digital Library
- A. Kennedy and D. Syme. Design and implementation of generics for the .NET Common Language Runtime. In PLDI, pages 1–12, 2001. Google Scholar
Digital Library
- B. Liskov, A. Snyder, R. Atkinson, and J. C. Schaffert. Abstraction mechanisms in CLU. Comm. of the ACM, 20(8):564–576, Aug. 1977. Google Scholar
Digital Library
- Also in S. Zdonik and D. Maier, eds., Readings in Object-Oriented Database Systems.Google Scholar
- B. Liskov, R. Atkinson, T. Bloom, J. E. Moss, J. C. Schaffert, R. Scheifler, and A. Snyder. CLU Reference Manual. Springer-Verlag, 1984. Google Scholar
Digital Library
- Also published as Lecture Notes in Computer Science 114, G. Goos and J. Hartmanis, Eds., Springer-Verlag, 1981.Google Scholar
- T. Millstein, M. Reay, and C. Chambers. Relaxed MultiJava: Balancing extensibility and modular typechecking. In Proc. 18th OOPSLA, pages 224–240, 2003. Google Scholar
Digital Library
- D. R. Musser, G. J. Derge, and A. Saini. The STL Tutorial and Reference Guide. Addison-Wesley, 2nd edition, 2001. ISBN 0-201- 37923-6. Google Scholar
Digital Library
- A. C. Myers, J. A. Bank, and B. Liskov. Parameterized types for Java. In Proc. 24th POPL, pages 132–145, Jan. 1997. Google Scholar
Digital Library
- N. C. Myers. Traits: a new and useful template technique. C++ Report, 7(5), June 1995.Google Scholar
- N. Nystrom, M. R. Clarkson, and A. C. Myers. Polyglot: an extensible compiler framework for Java. In Proc. 12th Int’l Conf. on Compiler Construction (CC’03), volume 2622 of Lecture Notes in Computer Science, pages 138–152, 2003. Google Scholar
Digital Library
- M. Odersky. The Scala Language Specification. EPFL, 2014. Version 2.9.Google Scholar
- B. C. Oliveira, A. Moors, and M. Odersky. Type classes as objects and implicits. In Proc. 25th OOPSLA, pages 341–360, 2010. Google Scholar
Digital Library
- B. C. Oliveira, T. Schrijvers, W. Choi, W. Lee, and K. Yi. The implicit calculus: A new foundation for generic programming. In PLDI, pages 35–44, 2012. Google Scholar
Digital Library
- S. Peyton-Jones, M. Jones, and E. Meijer. Type classes: an exploration of the design space. In Haskell Workshop, 1997.Google Scholar
- Rust. Rust programming language. http://doc.rust-lang.org/1.0.0-beta, 2015.Google Scholar
- C. Schaffert, T. Cooper, B. Bullis, M. Kilian, and C. Wilpolt. An introduction to Trellis/Owl. In Proc. 1st OOPSLA, Sept. 1986. Google Scholar
Digital Library
- J. G. Siek. The C++0x concepts effort. Arxiv preprint arXiv:1201.0027, Dec. 2011.Google Scholar
- J. G. Siek and A. Lumsdaine. Essential language support for generic programming. In PLDI, pages 73–84, 2005. Google Scholar
Digital Library
- J. G. Siek and A. Lumsdaine. A language for generic programming in the large. Science of Computer Programming, 76(5):423–465, 2011. Google Scholar
Digital Library
- M. Sulzmann, G. J. Duck, S. Peyton-Jones, and P. J. Stuckey. Understanding functional dependencies via constraint handling rules. J. Funct. Program., 17(1):83–129, Jan. 2007. Google Scholar
Digital Library
- Swift. Swift programming language. https://developer.apple.com/swift/resources/, 2014.Google Scholar
- M. Torgersen, C. P. Hansen, E. Ernst, P. von der Ahé, G. Bracha, and N. Gafter. Adding wildcards to the Java programming language. In Proc. 2004 ACM Symposium on Applied Computing, SAC ’04, pages 1289–1296, 2004. Google Scholar
Digital Library
- P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In Proc. 16th POPL, pages 60–76, 1989. Google Scholar
Digital Library
- A. Warth, M. Stanojevi´c, and T. Millstein. Statically scoped object adaptation with expanders. In Proc. 21st OOPSLA, Oct. 2006. Google Scholar
Digital Library
- S. Wehr and P. Thiemann. JavaGI: The interaction of type classes with interfaces and inheritance. ACM Trans. Prog. Lang. Syst., 33(4):12:1– 12:83, July 2011. Google Scholar
Digital Library
- Y. Zhang, M. C. Loring, G. Salvaneschi, B. Liskov, and A. C. Myers. Genus: Making generics object-oriented, expressive, and lightweight. Technical Report http://hdl.handle.net/1813/39910, Cornell University, Apr. 2015.Google Scholar
Index Terms
Lightweight, flexible object-oriented generics
Recommendations
Lightweight, flexible object-oriented generics
PLDI '15: Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and ImplementationThe support for generic programming in modern object-oriented programming languages is awkward and lacks desirable expressive power. We introduce an expressive genericity mechanism that adds expressive power and strengthens static checking, while ...
Associated types and constraint propagation for mainstream object-oriented generics
Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming systems languages and applicationsSupport for object-oriented programming has become an integral part of mainstream languages, and more recently generic programming has gained widespread acceptance as well. A natural question is how these two paradigms, and their underlying language ...
Associated types and constraint propagation for mainstream object-oriented generics
OOPSLA '05: Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applicationsSupport for object-oriented programming has become an integral part of mainstream languages, and more recently generic programming has gained widespread acceptance as well. A natural question is how these two paradigms, and their underlying language ...






Comments