Jump to content




[lua] [question] why should i use local variables?


  • You cannot reply to this topic
2 replies to this topic

#1 ETHANATOR360

  • Members
  • 423 posts
  • Locationyour hardrive

Posted 16 July 2012 - 08:11 PM

iv seen most people global using local variables in there programs and i want to know why should use them

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 16 July 2012 - 08:35 PM

Well, it's bad practice to use global variables. Any program can access them, so it brings security isues. If the only program running is yours, then it should be ok. But you can't ensure that (there could be some program running on the background), and one could mess up the other (you expected a variable to be of some type, but it changed in the other program and now your program crashes).
Also, global variables stay when the program ends, so you shouldn't store anything like passwords, etc. cause other program could read them.

#3 ETHANATOR360

  • Members
  • 423 posts
  • Locationyour hardrive

Posted 16 July 2012 - 08:50 PM

thanks :P/>





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users