元编程的用途是什么? [英] What's the use of metaprogramming?

查看:95
本文介绍了元编程的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过:

  • Wikipedia
  • Code Generation vs. Metaprogramming
  • The art of Metaprogramming
  • Metaprogramming at c2.com

我承认元编程/代码生成背后的目的有些混乱.

and I confess some confusion at the purpose behind metaprogramming/code generation.

有人在哪里使用元编程/代码生成的具体示例吗?更好的解释是为什么它比其他方法更好.

Does anyone have a concrete example of where they use metaprogramming/code generation? Even better would be an accompanying explanation of why it was better than an alternative.

修改: 将 Thistle 视为元编程?

推荐答案

想象一个制造汽车的人.说的和使用计算机一样.
在某个时刻,他意识到自己或多或少总是在做同一件事.
因此,他建立了工厂来制造汽车,而且情况要好得多.他现在正在编程!
不过,在某个时候,他再次意识到自己在某种程度上一直在做同样的事情.
现在,他决定建造工厂,建造可以生产汽车的工厂.那是元编程.

Imagine a guy who builds cars. Say it's the same thing as using a computer.
At some point he realizes he's always doing the same thing, more or less.
So he builds factories to build cars, and it's much better. He's now programming !
Nevertheless, once again, at some point, he realizes he's always doing the same thing, to some extent.
Now he decides to build factories that build factories that build cars. That's metaprogramming.

元编程功能非常强大,但是系统中的一个小故障会使所有优势变成了巨大的困难.因此,掌握它并使用它...或者远离吧!

Metaprogramming is immensely powerful, but one glitch in the system makes all advantages turn into monster difficulties. So master it and use it... Or stay away !

这篇关于元编程的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆