C++模板作为部分求值
C++ Templates as Partial Evaluation
摘要:
本文探讨了C++模板和部分求值之间的关系。模板被设计为支持泛型编程,但无意中提供了执行编译时计算和代码生成的能力。这些特性完全是偶然的,因此它们的语法很笨拙。通过在部分求值方面重铸这些特性,可以实现更简单的语法。C++可以被认为是一种两级语言,其中类型是第一类值。模板实例化类似于离线部分求值器。本文介绍了一个单一的机制的基础上部分评估,统一泛型编程,编译时计算和代码生成的初步工作。语言Catat介绍来说明这些想法。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。