After a considerable amount of fussing around, I figured out that tail recursion with a function produced with $varargs will not have the tail recursion optimized, at least not how I expected.

Example that loops forever:

test = function() {
       test();
}

test();

Example that results in stack overflow:

test_var = $varargs(function(args) {
       test_var();
});

test_var();


The same occurs with the following two examples, which are probably closer to my original issue.

Loops forever:

test = function() {
       test_var(test);
}

test_var = function(arg) {
       arg();
};

test();


Stack overflow:

test = function() {
       test_var(test);
}

test_var = $varargs(function(args) {
       args[0]();
});

test();

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

Is there any way to have this work?

Thanks,
Justin

--
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to