We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class Main { static function main() { for_loop(4, function (x) return x < 10, function (x) return x + 1, function (x) trace("int " + x)); for_loop(4.0, function (x) return x < 10.0, function (x) return x + 1.0, function (x) trace("float " + x)); for_loop("", function (x) return x.length < 10, function (x) return x + "-", function (x) trace("string " + x)); } @:generic static function for_loop<T>(v:T, condition:T->Bool, next:T->T, block:T->Void) { if (condition(v)) { block(v); for_loop(next(v), condition, next, block); } } }
haxe -D js_es5 -D analyzer -js main.js -main Main
(function () { "use strict"; var Main = function() { }; Main.for_loop_String = function(v,condition,next,block) { if(condition(v)) { block(v); Main.for_loop_for_loop_T(next(v),condition,next,block); } }; Main.for_loop_Float = function(v,condition,next,block) { if(condition(v)) { block(v); Main.for_loop_for_loop_T(next(v),condition,next,block); } }; Main.for_loop_Int = function(v,condition,next,block) { if(condition(v)) { block(v); Main.for_loop_for_loop_T(next(v),condition,next,block); } }; Main.main = function() { Main.for_loop_Int(4,function(x) { return x < 10; },function(x1) { return x1 + 1; },function(x2) { console.log("int " + x2); }); Main.for_loop_Float(4.0,function(x3) { return x3 < 10.0; },function(x4) { return x4 + 1.0; },function(x5) { console.log("float " + x5); }); Main.for_loop_String("",function(x6) { return x6.length < 10; },function(x7) { return x7 + "-"; },function(x8) { console.log("string " + x8); }); }; Main.main(); })();
The text was updated successfully, but these errors were encountered:
error on recursive @:generic functions for now (see #3523)
@:generic
544bc92
I"ve made it error in the recursive case for now, which is better than generating nonsense code.
I want to support this properly too, but it"s not trivial because it means delaying the generic expansion until the concrete types are available.
Sorry, something went wrong.
We can"t delay this at the moment because we lose the type parameter information. Fixing this is going to require AST changes (see https://groups.google.com/forum/#!topic/haxedev/M96qHOYCLsI).
Simn
No branches or pull requests
The text was updated successfully, but these errors were encountered: