Jump to content




Are global variables actually global?


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

#1 Graypup

  • Members
  • 90 posts

Posted 16 June 2012 - 12:42 AM

Are global variables created in one CC program accessible from another?

#2 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 16 June 2012 - 12:47 AM

Yes, they are stored in the global table, so you can access them from another program. It's not good practice though.

Edit: just checked the shell program, and each shell creates an environment to run the programs, so the variables will be global to the shell that's running the program.

#3 kazagistar

  • Members
  • 365 posts

Posted 16 June 2012 - 12:54 AM

The os loaded APIs have namespaces, so if you set a global in one of those, it just becomes one of the local attributes of the API's table.

Also note, the global scope applies to functions as well.

#4 Graypup

  • Members
  • 90 posts

Posted 16 June 2012 - 05:49 PM

OK, fortunately I just read programming in lua, so I actually remember what that means. Anyway, thanks.
Also, is it possible to create truly global variables?
I was intending to create variables for functions that are super-annoying to type the names of.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users