Originally Posted by skyraker
Thanks you for all the replies so far. Scope is always a fun topic.
1) Like all the talk about using spacer as a global, but my addon didn't call it simply that. Looking at things, I managed to completely rid it as a global though.
2) If a global in the lua file is available to all addons, and making it a local outside the scope of any function makes it only available to the addon, then I may have my problem solved in a sense without much of a change. When I was thinking of it as a global, I was thinking only that it was global to the addon. If that is more 'acceptable', then maybe it is best to keep things that way (but just in case ensure all my variables aren't easily reproducible by other addons).
|
Nah, it's still global, you just have a local reference.
MyUniqueAddonName_LastQuestID = 1 ... This is a global variable
local lastQuestID = MyUniqueAddonName ... this gives you a local version of the variable
As far as I know this would either branch, so to speak, the variable so that now there is a global version and a local version. Whether they co-exist or not I don't know. I think I have read both sides of that conversation and still aren't sure of when allocation is just a reference or whether it is another copy of the variable. Possibly functions and tables are referenced and others are just plain values