no edit summary
m (→Complex Scope: Corrected a mistake in the example) |
No edit summary |
||
| Line 4: | Line 4: | ||
[[Addons]] in World of Warcraft share a single [[execution environment]]. As a result, all addons have access to the same global variables. If one addon creates a global variable named "foo," then all other addons can use (or overwrite) that same variable. This allows for some really useful things to happen; the most frequently used tactic that takes advantage of this feature is [[HOWTO:_Hook_a_Function|hooking]]. Unfortunately, this can also cause some problems in addons. They will conflict if they both try to use the same name for a variable. As a result, addon authors must ensure that their addons don't conflict by doing one (or more) of the following: | [[Addons]] in World of Warcraft share a single [[execution environment]]. As a result, all addons have access to the same global variables. If one addon creates a global variable named "foo," then all other addons can use (or overwrite) that same variable. This allows for some really useful things to happen; the most frequently used tactic that takes advantage of this feature is [[HOWTO:_Hook_a_Function|hooking]]. Unfortunately, this can also cause some problems in addons. They will conflict if they both try to use the same name for a variable. As a result, addon authors must ensure that their addons don't conflict by doing one (or more) of the following: | ||
#Using assuredly-unique names for variables, such as MyAddon_MyFrame_OnLoad | #Using assuredly-unique names for variables, such as MyAddon_MyFrame_OnLoad | ||
# | #Making their addons [[Object_Oriented_Programming|object-oriented]] | ||
#Using variable ''scope'' to the author's advantage. | #Using variable ''scope'' to the author's advantage. | ||