PtokaX forum

Archive => HOW-TO's => Archived 5.1 boards => Old HOW-TO's => Topic started by: Markitos on 12 June, 2006, 09:36:44

Title: Global var VS Local var
Post by: Markitos on 12 June, 2006, 09:36:44
...what are the diffs between the too?
Title: Re: Global var VS Local var
Post by: Thor on 12 June, 2006, 10:00:33
Global variables can use everywhere in the script, in any function, they will reachable in the whole script, and they will on the memory while the script is running. Local variables will stop when you put the end of the function, if or for, and will delete from the memory. So local variables (and tables also) are better, than global ones.
Title: Re: Global var VS Local var
Post by: Markitos on 12 June, 2006, 10:10:43
Quote from: Hungarista on 12 June, 2006, 10:00:33
Global variables can use everywhere in the script, in any function, they will reachable in the whole script, and they will on the memory while the script is running. Local variables will stop when you put the end of the function, if or for, and will delete from the memory. So local variables (and tables also) are better, than global ones.
Thanks!
Title: Re: Global var VS Local var
Post by: GeceBekcisi on 12 June, 2006, 11:35:38
I wonder, if local variables are deleted from memory on function exit or garbage collection?
Title: Re: Global var VS Local var
Post by: Dessamator on 12 June, 2006, 23:08:58
On function exit, under normal conditions.
Title: Re: Global var VS Local var
Post by: Dessamator on 13 June, 2006, 10:13:31
Nicely quoted Mutor, though that only answers the first Markitos' question, and not GeceBekcisi's.
Title: Re: Global var VS Local var
Post by: Dessamator on 14 June, 2006, 10:29:10
Indeed, I did but I just wanted to be certain.