1583 posts
Location
Germany
Posted 20 May 2013 - 05:54 AM
I heared that, if you have a program (for example: test) and in this program are some lines of code. at the end you restart it with shell.run('test').
Why is this "bad"?
7508 posts
Location
Australia
Posted 20 May 2013 - 06:04 AM
Well I guess the easiest way for me to answer is to tell you to run this program and see what happens
program name:
tester
shell.run('tester')
yep thats right, stackoverflow. using
shell.run at the end of your program to loop your program is recursion.
1688 posts
Location
'MURICA
Posted 20 May 2013 - 06:05 AM
So in other words, it's the same as doing this:
function toaster()
toaster()
end
1511 posts
Location
Pennsylvania
Posted 20 May 2013 - 07:34 AM
Reason: The stack in Lua is like a pile of clean dishes. Too many dishes and the stack crashes down. If a function yields however, it will be taken off the stack. Guess what, using recursion (in most cases) does not yield. So just don't use it if the situation you are using it in does not need it.