[英]CFor in Haxe using Macros
所以,我喜欢宏(对我大喊大叫)。
我试图在Haxe中创建一个宏,它允许我编写传统的(C ++,Java)for循环并具有相同的功能。 但我是Haxe的初学者......
码:
import haxe.macro.Expr;
class Cfor {
macro public static function cfor(init: Expr, cond: Expr, post: Expr, body: Expr) {
return macro {
$init;
while ($cond) {
$body;
$post;
}
}
}
public static function main() {
trace("Traced");
cfor(var i = 0, i < 100, i++, {
var x = i * 2;
trace(x);
});
}
}
问题 :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.