So, I recently came across a case where I needed to write code where callback calls itself, etc., and wondered about NodeJS support and the tail of the call, so I found this answer https://stackoverflow.com/a/212616/2/ . saying yup, he maintained.
So, I tried this with this simple code:
"use strict";
function fac(n){
if(n==1){
console.trace();
return 1;
}
return n*fac(n-1);
}
fac(5);
Using Node 6.9.2 on Linux x64 and run it as the node tailcall.js --harmony --harmony_tailcalls --use-strict
result was:
Trace
at fac (/home/tailcall.js:4:11)
at fac (/home/tailcall.js:7:11)
at fac (/home/tailcall.js:7:11)
at fac (/home/tailcall.js:7:11)
at fac (/home/tailcall.js:7:11)
at Object.<anonymous> (/home/tailcall.js:10:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
Which clearly shows that the column is filled with calls, and tail recursion is not supported, although I use the latest NodeJS.
NodeJS/JavaScript ?
, , , , , - , .