Skip to content
New issue

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

Unable to recursively call named lambda #22

Open
smagnuso opened this issue Jul 1, 2017 · 1 comment
Open

Unable to recursively call named lambda #22

smagnuso opened this issue Jul 1, 2017 · 1 comment

Comments

@smagnuso
Copy link

smagnuso commented Jul 1, 2017

function outer()
{
    return function inner(x) {
         if(x == 10)
              return x;
         return inner.call(x, x+1);
    }(0);
}
console.log("Done: " + outer());

Any thoughts? I tried to implement it, but ended up butchering it :)

@daurnimator
Copy link

$ ../bin/castl.js --cat issue-22.lua

-- Lua code (Lua 5.2):
--------------------------------------------------------------------
local _ENV = require("castl.runtime");
local outer;

outer = (function (this)
do return (function (this, x)
if (_eq(x,10)) then
do return x; end
end

do return inner:call(x,(_addNum2(x,1))); end
end)(_ENV,0); end
end);
console:log((_addStr1("Done: ",outer(_ENV))));

--------------------------------------------------------------------

Looks like the anonymous function doesn't get named. i.e. this is a CASTL bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants