A Semantic Analysis of C++ Templates
2006 (English)In: ECOOP 2006 - Object-Oriented Programming: 20th European Conference, Nantes, France, July 3-7, 2006, Proceedings / [ed] Dave Thomas, Heidelberg: Springer, 2006, p. 304-327Conference paper, Published paper (Refereed)
Abstract [en]
Templates are a powerful but poorly understood feature ofthe C++ language. Their syntax resembles the parameterized classes ofother languages (e.g., of Java). But because C++ supports template specialization, their semantics is quite different from that of parameterizedclasses. Template specialization provides a Turing-complete sub-languagewithin C++ that executes at compile-time. Programmers put this powerto many uses. For example, templates are a popular tool for writingprogram generators.The C++ Standard defines the semantics of templates using natural language, so it is prone to misinterpretation. The meta-theoretic propertiesof C++ templates have not been studied, so the semantics of templateshas not been systematically checked for errors. In this paper we presentthe first formal account of C++ templates including some of the morecomplex aspects, such as template partial specialization. We validate oursemantics by proving type safety and verify the proof with the Isabelleproof assistant. Our formalization reveals two interesting issues in theC++ Standard: the first is a problem with member instantiation and thesecond concerns the generation of unnecessary template specializations.
Place, publisher, year, edition, pages
Heidelberg: Springer, 2006. p. 304-327
Series
Lecture Notes in Computer Science, ISSN 0302-9743 ; 4067
Keywords [en]
Codes (symbols), Error correction, High level languages, Natural language processing systems, Parameter estimation, Security of data, Semantics, Standards
National Category
Computer Systems
Identifiers
URN: urn:nbn:se:hh:diva-20971DOI: 10.1007/11785477_19ISI: 000239558900018Scopus ID: 2-s2.0-33746612005ISBN: 3-540-35726-2 ISBN: 978-3-540-35726-1 OAI: oai:DiVA.org:hh-20971DiVA, id: diva2:588267
Conference
20th European Conference on Object-Oriented Programming (ECOOP 2006), Nantes, FRANCE, APR 03-JUL 07, 2006
2013-01-152013-01-142021-05-11Bibliographically approved