m
no edit summary
No edit summary |
mNo edit summary |
||
| Line 20: | Line 20: | ||
=== Lua Namespaces === | === Lua Namespaces === | ||
In Lua, namespaces don't directly exist. However, Lua programmers typically take advantage of several key, and unique, features which are available in the language to provide a indirect mechanism which can be considered setting up a namespace. Some other programmers, unfamiliar with languages that don't allow for the creation of namespaces, may confuse these with classes, but the major difference is that only one instance of a namespace ever exists, while there can be many separate instances of a class. | In [[Lua]], namespaces don't directly exist. However, Lua programmers typically take advantage of several key, and unique, features which are available in the language to provide a indirect mechanism which can be considered setting up a namespace. Some other programmers, unfamiliar with languages that don't allow for the creation of namespaces, may confuse these with classes, but the major difference is that only one instance of a namespace ever exists, while there can be many separate instances of a class. | ||
In Lua, a function is a variable. As such, it should be noted that a reference to a function can be used wherever a variable is used. The implications of this is that functions can be stored inside tables. Furthermore, in WoW, all addons share the same [[execution environment]], therefore it is vital that some form of [[Lua_Scope|scope limitation]] is used so common variable names do not cause addon conflicts. Namespaces are one such method to organize code, thus limiting conflicts. | In Lua, a function is a variable. As such, it should be noted that a reference to a function can be used wherever a variable is used. The implications of this is that functions can be stored inside tables. Furthermore, in WoW, all addons share the same [[execution environment]], therefore it is vital that some form of [[Lua_Scope|scope limitation]] is used so common variable names do not cause addon conflicts. Namespaces are one such method to organize code, thus limiting conflicts. | ||
| Line 245: | Line 245: | ||
end | end | ||
[[Category: | [[Category:Interface Customization]] | ||
[[Category:Glossary]] | |||
[[Category:Guides]] | |||
[[Category:Lua functions| Object Oriented Programming]] | |||