元编程 / 元编程技术:一种编程方式,程序把“代码”当作数据来读取、生成、修改或分析,从而在编译期或运行期自动产生或改变程序结构。常见于宏(macros)、模板(templates)、反射(reflection)、代码生成(code generation)等场景。(也可泛指“写能够写程序的程序”。)
/ˌmɛtəˈproʊɡræmɪŋ/
Metaprogramming can reduce repetitive code in large projects.
元编程可以减少大型项目中的重复代码。
By using metaprogramming, the library generates optimized functions at compile time, but the added complexity can make debugging harder.
通过元编程,这个库在编译期生成优化过的函数,但额外的复杂性也可能让调试更困难。
由 **meta-**(“关于……本身、超越/更高层次”)+ programming(“编程”)构成。字面意思是“关于编程的编程”,强调在更高层次上对代码进行操作,让程序能够生成或改写程序。