Thread: Addon Etiquette
View Single Post
04/21/14, 12:11 PM   #24
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
Originally Posted by Seerah View Post
There is no such thing as a "local global" variable.
Bah, you are correct. This is just my bad terminology... :P
At the end of the day, it is just a local variable BUT it can be local to the scope of your entire file, for instance.

Originally Posted by Seerah View Post
What most people miss is that frame names are GLOBAL REFERENCES to that frame. These need to be uniquely named objects as well.
Lua Code:
  1. local frame = CreateFrame("MyFrame", GuiRoot, CT_CONTROL)
  2. --the local variable and the global reference both point to the same frame in memory
  3. d(frame)     --prints out userdata:459efj9
  4. d(MyFrame)     --prints out userdata:459efj9
If some other author also cleverly decides to give their control a global name of MyFrame, whichever one is created second will overwrite the first and the two addons will break each other. (The same is true for any other global variable.)
This!!! Great thing to point out! You have to treat your frame names with the same level of consideration that you do any other global variable because they are exposed globally!

Honestly, I live by the rule that "It's better to be safe than sorry." If you are passing some sort of name string to a function and you are not entirely sure if it is global or local (and can't/won't do the leg work to figure it out) just use the MyAddonname_ sort of standard, as Seerah reiterated. Then you just don't have to be concerned. :P
  Reply With Quote