Jump to content

Stack overflow


[DMC]

Recommended Posts

Posted

hey,

i got a script for the admins when i do /admins it says

Level 10=

level 9=

etc

but when i do this its saying stack overflow :mrgreen:

im not comfortable with posting this

so im just asking what this error means :|

Posted

That the stack has overflown. I've only ever reproduced this by calling a function from within itself, like;

function a() a() end 

Posted
hey,

i got a script for the admins when i do /admins it says

Level 10=

level 9=

etc

but when i do this its saying stack overflow :mrgreen:

im not comfortable with posting this

so im just asking what this error means :|

there are at lest two ways to prevent this:

1) Proper Tail Call

function a()  
 return a()  
end 

Because a proper tail call uses no stack space, there is no limit on the number of "nested" tail calls that a program can make. For instance, we can call the following function with any number as argument; it will never overflow the stack.

2) setTimer function

function a()  
 setTimer (a,50,1)  
end 

i always use "setTimer" method myself, ofcourse the interval may be difrent than 50 (50 is minimum)

Posted

i was bored in the work one day and i read the lua manual...

this expresion

function a() 
  return a() 
end 

is a "Proper Tail Cal" and lua interpreter treats it like "GoTo" and do not use any stack space. No stack -> no stack overflow

http://www.lua.org/pil/6.3.html

of course every scripter should know how to prevent Infinite loops using conditions ;) and i think this exemple may result in FPS drop.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...