Skip to content

Instantly share code, notes, and snippets.

@YellowAfterlife
Created December 27, 2014 15:44
Show Gist options
  • Save YellowAfterlife/d8fbdb7ce327c3196231 to your computer and use it in GitHub Desktop.
Save YellowAfterlife/d8fbdb7ce327c3196231 to your computer and use it in GitHub Desktop.
C-style for-loop for Haxe-JS. The real one this time! Requires a git version of Haxe.
class Main {
macro public static function forc(init, condition, post, block) {
return macro untyped __js__("for ({0}; {1}; {2}) {3}", $init, $condition, $post, $block);
}
static function main() {
forc(var i = 0, i < 5, i++, {
trace(i);
trace("..!!");
});
}
}
/*
(function () { "use strict";
var console = (1,eval)('this').console || {log:function(){}};
var Main = function() { };
Main.main = function() {
for (var i = 0; i < 5; i++) {
console.log(i);
console.log("..!!");
}
};
Main.main();
})();
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment