So, I love macros (yell at me).
I was trying to create a macro in Haxe, which allows me to write the traditional (C++, Java) for-loop and have the same functionality. But I am quite a beginner in Haxe...
Code:
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);
});
}
}
Questions :
What about this?
https://gist.github.com/dpeek/7476625
The approach is different (applied to the context) but I think it is a little closer to the desired outcome.
I don't see any potential target specific issues with your code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.