Maris Posted September 7, 2015 Share Posted September 7, 2015 I always use_G = GLOBALBecause GLOBAL._G == GLOBALi.e. _G == _G._GSo _G always defined and works fine irrespective of, whether the GLOBAL variable is defined.My question is about "local" statement.Is there difference for optimization between_G = GLOBALandlocal _G = GLOBALI noticed that I can get variables of local "global space" of other mods by usinglocal env = _G.ModManager:GetMod("modname").envBut there are only "globals", not "locals". E.g. I can use env.x if and only if there is global definition (x=5), and I can't use env.x if there is only local definition (local x=5).So there is some difference. But is there difference for optimization?I read some lua optimization tips. They said that local variables are very fast. But I'm not sure about variable in local global space (environment of the mod). It seems that they are in the same scope. Only difference that locals are invisible for accessing from outside. That's it. So is there any real difference for optimization? Does anybody know? Link to comment Share on other sites More sharing options...
ZupaleX Posted September 7, 2015 Share Posted September 7, 2015 It is not really clear what you are asking. I do not see the link between asking if you should write _G = GLOBALorlocal _G = GLOBALand the impossibility to retrieve local variables from other mods (well, they are... local). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now