C++ Templates as Partial Evaluation
Todd L. Veldhuizen

TL;DR
This paper reinterprets C++ templates as a form of partial evaluation, proposing a unified mechanism that simplifies syntax and integrates generic programming, compile-time computation, and code generation.
Contribution
It introduces a new perspective viewing C++ templates through partial evaluation, and presents the language Catat to demonstrate this unified approach.
Findings
Templates support compile-time computations and code generation.
Recasting templates as partial evaluation simplifies syntax.
Proposes a unified mechanism for generic programming and code generation.
Abstract
This paper explores the relationship between C++ templates and partial evaluation. Templates were designed to support generic programming, but unintentionally provided the ability to perform compile-time computations and code generation. These features are completely accidental, and as a result their syntax is awkward. By recasting these features in terms of partial evaluation, a much simpler syntax can be achieved. C++ may be regarded as a two-level language in which types are first-class values. Template instantiation resembles an offline partial evaluator. This paper describes preliminary work toward a single mechanism based on Partial Evaluation which unifies generic programming, compile-time computation and code generation. The language Catat is introduced to illustrate these ideas.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLogic, programming, and type systems · Parallel Computing and Optimization Techniques · Advanced Software Engineering Methodologies
