I'm working on a Scratch programming game in HTML5 and JS. Let us assume that there're code-blocks(sprites) and function-blocks which one can fill in with code-blocks. And assume that i want it work recursively, i.e. one can put a function into another function or into itself as well. The idea is to program a robot for it's movement. Assume, that in the game i create function f3(x) and put en arrow-block in it. then i create function f4(x) and put f3(x) and an arrow in it. Then I put f4(f3(arrow), arrow)-block in the commando-line. Then i write some an recursive function.
RecursiveFunc: function(codeBlock) {
For(i=0;i<commandoLine;i++){
if(inArray(block, functions)===true){
RecursiveFunc(commandoLine[i])}
else{
executeArray.push(codeBlock)
}
}
}
What really happens is that when the function reads f4-block, then detects f3 and executes itself and reads the arrow in f3, then it doesn't continue to read the arrow in f4(f3, arrow), as it would work like that, for example, in Python. Is it a kind of TCO-absence problem? And how can one workaround it in JavaScript?
Thanks!