ABSTRACT
Generic programming has recently emerged as a paradigm for developing highly reusable software libraries, most notably in C++. We have designed and implemented a constrained generics extension for C++ to support modular type checking of generic algorithms and to address other issues associated with unconstrained generics. To be as broadly applicable as possible, generic algorithms are defined with minimal requirements on their inputs. At the same time, to achieve a high degree of efficiency, generic algorithms may have multiple implementations that exploit features of specific classes of inputs. This process of algorithm specialization relies on non-local type information and conflicts directly with the local nature of modular type checking. In this paper, we review the design and implementation of our extensions for generic programming in C++, describe the issues of algorithm specialization and modular type checking in detail, and discuss the important design tradeoffs in trying to accomplish both.We present the particular design that we chose for our implementation, with the goal of hitting the sweet spot in this interesting design space.
- Matthew H. Austern. Generic programming and the STL: Using and extending the C++ Standard Template Library. Professional Computing Series. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1998.]] Google Scholar
Digital Library
- D. G. Bobrow, L. G. DeMichiel, R. P. Gabriel, S. E. Keene, G. Kicsales, and D. A. Moon. Common LISP Object System specification X3J13 document 88-002R. SIGPLAN Not., 23(SI):1--143, 1988.]] Google Scholar
Digital Library
- Daniel G. Bobrow, Kenneth Kahn, Gregor Kiczales, Larry Masinter, Mark Stefik, and Frank Zdybel. CommonLoops: Merging Lisp and object-oriented programming. In OOPSLA '86: Conference proceedings on Object-oriented programming systems, languages and applications, pages 17--29, New York, NY, USA, 1986. ACM Press.]] Google Scholar
Digital Library
- Manuel M. T. Chakravarty, Gabrielle Keller, and Simon Peyton Jones. Associated type synonyms. In ICFP '05: Proceedings of the International Conference on Functional Programming, pages 241--253, New York, NY, USA, September 2005. ACM Press.]] Google Scholar
Digital Library
- Manuel M. T. Chakravarty, Gabrielle Keller, Simon Peyton Jones, and Simon Marlow. Associated types with class. In POPL '05: Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 1--13, New York, NY, USA, 2005. ACM Press.]] Google Scholar
Digital Library
- Craig Chambers. Object-oriented multi-methods in Cecil. In Ole Lehrmann Madsen, editor, Proceedings of the 6th European Conference on Object-Oriented Programming (ECOOP), volume 615 of Lecture Notes in Computer Science, pages 33--56, Berlin, Heidelberg, New York, Tokyo, 1992. Springer-Verlag.]] Google Scholar
Digital Library
- Craig Chambers. Predicate classes. In ECOOP'93 - Object-Oriented Programming, volume 707 of Lecture Notes in Computer Science, pages 268--296, 1993.]] Google Scholar
Digital Library
- Craig Chambers and Gary T. Leavens. Typechecking and modules for multimethods. ACM Trans. Program. Lang. Syst., 17(6):805--843, 1995.]] Google Scholar
Digital Library
- Craig Chambers and the Cecil Group. The Cecil Language: Specification and Rationale, Version 3.1. University of Washington, Computer Science and Engineering, December 2002. http://www.cs.washington.edu/research/projects/cecil/.]]Google Scholar
- Gabriel Dos Reis and Bjarne Stroustrup. Specifying C++ concepts. In POPL '06: Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 295--308, New York, NY, USA, 2006. ACM Press.]] Google Scholar
Digital Library
- Michael D. Ernst, Crag Kaplan, and Craig Chambers. Predicate dispatching: A unified theory of dispatch. In ECOOP '98, volume 1445 of Lecture Notes in Computer Science, pages 186--211, New York, NY, 1998. Springer-Verlag.]] Google Scholar
Digital Library
- A. Fabri, G.-J. Giezeman, L. Kettner, S. Schirra, and S. Schönherr. On the design of CGAL, a computational geometry algorithms library. Software-Practice and Experience, 30(11):1167--1202, 2000. Special Issue on Discrete Algorithm Engineering.]] Google Scholar
Digital Library
- Ronald Garcia, Jaakko Järvi, Andrew Lumsdaine, Jeremy Siek, and Jeremiah Willcock. A comparative study of language support for generic programming. In OOPSLA '03: Proceedings of the 18th annual ACM SIGPLAN conference on Object-oriented programing, systems, languages, and applications, pages 115--134, New York, NY, USA, 2003. ACM Press.]] Google Scholar
Digital Library
- James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification, Third Edition. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 2005.]] Google Scholar
Digital Library
- Douglas Gregor. ConceptGCC: Concept extensions for C++. http://www.osl.iu.edu/~dgregor/ConceptGCC, 2005.]]Google Scholar
- Douglas Gregor, Jeremy Siek, Jeremiah Willcock, Jaakko Järvi, Ronald Garcia, and Andrew Lumsdaine. Concepts for C++0x (revision 1). Technical Report N1849=05-0109, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, Programming Language C++, August 2005.]]Google Scholar
- International Organization for Standardization. ISO/IEC 14882:1998: Programming languages - C++. Geneva, Switzerland, September 1998.]]Google Scholar
- Jaakko Järvi, Jeremiah Willcock, and Andrew Lumsdaine. Conceptcontrolled polymorphism. In Frank Pfennig and Yannis Smaragdakis, editors, Generative Programming and Component Engineering, volume 2830 of LNCS, pages 228--244. Springer Verlag, September 2003.]] Google Scholar
Digital Library
- Jaakko Järvi, JeremiahWillcock, and Andrew Lumsdaine. Associated types and constraint propagation for mainstream object-oriented generics. In OOPSLA, October 2005.]] Google Scholar
Digital Library
- Mark P. Jones. Dictionary-free overloading by partial evaluation. In Partial Evaluation and Semantics-Based Program Manipulation, Orlando, Florida, June 1994 (Technical Report 94/9, Department of Computer Science, University of Melbourne), pages 107--117, 1994.]]Google Scholar
- Mark P. Jones. Qualified Types: Theory and Practice. Distinguished Dissertations in Computer Science. Cambridge University Press, 1994.]] Google Scholar
Digital Library
- Oleg Kiselyov. Dynamic dispatch on a class of a type. Haskell mailing list, March 2003. http://okmij.org/ftp/Haskell/types.html#class-based-dispatch.]]Google Scholar
- Xavier Leroy. Manifest types, modules, and separate compilation. In Proceedings of the 21st Annual ACM Symposium on Principles of Programming Languages, pages 109--122, 1994.]] Google Scholar
Digital Library
- Mark Lillibridge. Translucent Sums: A Foundation for Higher-Order Module Systems. PhD thesis, Pittsburgh, PA, May 1997.]]Google Scholar
- Brian McNamara and Yannis Smaragdakis. Static interfaces in C++. In First Workshop on C++ Template Programming, October 2000.]]Google Scholar
- Bertrand Meyer. Eiffel: the Language. Prentice Hall, New York, NY, first edition, 1992.]] Google Scholar
Digital Library
- Microsoft Corporation. Generics in C#, September 2002. Part of the Gyro distribution of generics for .NET available at http: //research.microsoft.com/projects/clrgen/.]]Google Scholar
- Microsoft Corporation. C# Version 2.0 Specification, March 2005 Draft, March 2005. http://msdn.microsoft.com/vcsharp/-programming/language.]]Google Scholar
- Todd Millstein and Craig Chambers. Modular statically typed multimethods. In Proceedings of the Thirteenth European Conference on Object-Oriented Programming (ECOOP'99), volume 1628 of Lecture Notes in Computer Science, pages 279--303, Lisbon, Portugal, June 1999. Springer Verlag.]] Google Scholar
Digital Library
- Todd Millstein, Mark Reay, and Craig Chambers. Relaxed MultiJava: balancing extensibility and modular typechecking. In OOPSLA'03: Proceedings of the 18th annual ACM SIGPLAN conference on Object-oriented programing, systems, languages, and applications, pages 224--240, New York, NY, USA, 2003. ACM Press.]] Google Scholar
Digital Library
- Robin Milner, Mads Tofte, and Robert Harper. The Definition of Standard ML. MIT Press, 1990.]] Google Scholar
Digital Library
- David A. Musser and Alexander A. Stepanov. Generic Programming. In Proceedings of International Symposium on Symbolic and Algebraic Computation, volume 358 of Lecture Notes in Computer Science, pages 13--25, Rome, Italy, 1989.]] Google Scholar
Digital Library
- Martin Odersky and al. An overview of the Scala programming language. Technical Report IC/2004/64, EPFL Lausanne, Switzerland, 2004.]]Google Scholar
- Martin Odersky and Matthias Zenger. Scalable component abstractions. SIGPLAN Not., 40(10):41--57, 2005.]] Google Scholar
Digital Library
- Simon Peyton Jones, Mark Jones, and Erik Meijer. Type classes: an exploration of the design space. In Proceedings of the Second Haskell Workshop, June 1997.]]Google Scholar
- Jeremy Siek. A Language for Generic Programming. PhD thesis, Indiana University, 2005.]] Google Scholar
Digital Library
- Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine. The Boost Graph Library: User Guide and Reference Manual. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 2002.]] Google Scholar
Digital Library
- Jeremy Siek and Andrew Lumsdaine. A modern framework for portable high performance numerical linear algebra. In Modern Software Tools for Scientific Computing. Birkhäuser, 1999.]]Google Scholar
- Jeremy Siek and Andrew Lumsdaine. Concept checking: Binding parametric polymorphism in C++. In First Workshop on C++ Template Programming, October 2000.]]Google Scholar
- Jeremy Siek and Andrew Lumsdaine. Essential language support for generic programming. In PLDI '05: Proceedings of the ACM SIGPLAN 2005 conference on Programming language design and implementation, pages 73--84, New York, NY, USA, June 2005. ACM Press.]] Google Scholar
Digital Library
- Silicon Graphics, Inc. SGI Implementation of the Standard Template Library, 2004. http://www.sgi.com/tech/stl/.]]Google Scholar
- A. Stepanov and M. Lee. The Standard Template Library. Technical Report HPL-94-34(R.1), Hewlett-Packard Laboratories, April 1994. http://www.hpl.hp.com/techreports.]]Google Scholar
- Bjarne Stroustrup. Design and Evolution of C++. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1994.]] Google Scholar
Digital Library
- Bjarne Stroustrup. Concepts - a more abstract complement to type checking. Technical Report N1510=03-0093, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, Programming Language C++, October 2003. http://www.open-std.org/jtc1/sc22/wg21.]]Google Scholar
- Bjarne Stroustrup and Gabriel Dos Reis. Concepts - design choices for template argument checking. Technical Report N1522=03-0105, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, Programming Language C++, October 2003. http://www.open-std.org/jtc1/sc22/wg21.]]Google Scholar
- Bjarne Stroustrup and Gabriel Dos Reis. A concept design (rev. 1). Technical Report N1782=05-0042, ISO/IEC JTC 1, Information Technology, Subcommittee SC 22, Programming Language C++, May 2005.]]Google Scholar
- The GHC Team. The Glorious Glasgow Haskell Compilation System User's Guide, version 6.4.1 edition. http://www.haskell.org/ghc/docs/latest/html/users guide/index.html.]]Google Scholar
- P. Wadler and S. Blott. How to make ad-hoc polymorphism less adhoc. In ACM Symposium on Principles of Programming Languages, pages 60--76. ACM, January 1989.]] Google Scholar
Digital Library
- Jörg Walter and Mathias Koch. Boost Basic Linear Algebra. Boost, 2002. www.boost.org/libs/numeric.]]Google Scholar
Index Terms
Algorithm specialization in generic programming: challenges of constrained generics in C++
Recommendations
Algorithm specialization in generic programming: challenges of constrained generics in C++
Proceedings of the 2006 PLDI ConferenceGeneric programming has recently emerged as a paradigm for developing highly reusable software libraries, most notably in C++. We have designed and implemented a constrained generics extension for C++ to support modular type checking of generic ...
Concepts: linguistic support for generic programming in C++
OOPSLA '06: Proceedings of the 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applicationsGeneric programming has emerged as an important technique for the development of highly reusable and efficient software libraries. In C++, generic programming is enabled by the flexibility of templates, the C++ type parametrization mechanism. However, ...
Concepts: linguistic support for generic programming in C++
Proceedings of the 2006 OOPSLA ConferenceGeneric programming has emerged as an important technique for the development of highly reusable and efficient software libraries. In C++, generic programming is enabled by the flexibility of templates, the C++ type parametrization mechanism. However, ...







Comments