我想要一种用于元编程的预处理语言
我正在寻找一种类似于 PHP 的语言,但更简短——我很想将其称为“模板引擎”,但我很确定这是错误的术语。什么是正确的术语?文本预处理器?
不管怎样,我希望它是基于 .NET 的,因为我想用它来帮助编写 .NET 代码。因为 .NET 泛型不适合编写快速数字代码(已知的解决方法太麻烦且限制了我的需求),我想使用某种预处理语言编写一个数学库,该语言允许我输出 C# 代码。例如,我想生成一系列由各种数据类型(PointF、PointD、PointI 等)组成的“Point”类:
#foreach(($T, $Type) in {(F, float), (D, double), (I, int), ...}) #{
public struct Point$T {
public $Type X, Y;
...
}
#}
您有什么建议?
I'm looking for a language sort of like PHP, but more brief -- I'm tempted to call it a "templating engine" but I'm pretty sure that's the wrong term. What is the right term? A text preprocessor?
Anyway I'd like it to be .NET-based because I want to use it to help write .NET code. Because .NET generics are unsuited for writing fast numeric code (the known workaround is too cumbersome and limited for my needs), I'd like to write a math library using some sort of preprocessing language that allows me to output C# code. For example, I'd like to generate a series of "Point" classes made from various data types (PointF, PointD, PointI, etc.):
#foreach(($T, $Type) in {(F, float), (D, double), (I, int), ...}) #{
public struct Point$T {
public $Type X, Y;
...
}
#}
What can you fine people suggest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有机会尝试过 T4 模板吗?这对于您想要实现的目标来说应该足够了。 http://msdn.microsoft.com/en-us/library/bb126445.aspx
Have you had a chance to try T4 templates? That should be sufficient for what you are trying to achieve. http://msdn.microsoft.com/en-us/library/bb126445.aspx
T4 代码生成和模板引擎随 Visual Studio 一起提供。
还有字符串模板,具有 C# 端口。
The T4 code generation and templating engine comes with Visual Studio.
There's also String Template, which has a C# port.