Lightweight, flexible object-oriented generics
- 3 June 2015
- conference paper
- conference paper
- Published by Association for Computing Machinery (ACM) in Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation
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.Keywords
Funding Information
- MURI (FA9550-12-1-0400)
- European Research Council (321217)
- Bundesministerium für Bildung und Forschung (01IC12S01V)
- National Science Foundation (CCF-0964409)
- Office of Naval Research (N00014-13-1-0089)
- Quanta
This publication has 36 references indexed in Scilit:
- JavaGIACM Transactions on Programming Languages and Systems, 2011
- A language for generic programming in the largeScience of Computer Programming, 2011
- Understanding functional dependencies via constraint handling rulesJournal of Functional Programming, 2007
- Object-oriented multi-methods in CecilPublished by Springer Science and Business Media LLC ,2006
- Polyglot: An Extensible Compiler Framework for JavaLecture Notes in Computer Science, 2003
- Featherweight JavaACM Transactions on Programming Languages and Systems, 2001
- Design and implementation of generics for the .NET Common language runtimeACM SIGPLAN Notices, 2001
- A statically safe alternative to virtual typesPublished by Springer Science and Business Media LLC ,1998
- Subtypes vs. where clausesACM SIGPLAN Notices, 1995
- Abstraction mechanisms in CLUCommunications of the ACM, 1977