Lua: Difference between revisions

No edit summary
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 2: Line 2:
{{Software
{{Software
  |name        = Lua
  |name        = Lua
|image      = Lua-Logo.svg.png
  |type        = Library
  |type        = Library
  |authors    = Roberto Ierusalimschy
  |authors    = Roberto Ierusalimschy
Line 18: Line 19:


Lua originated in 1993 as a language for extending software applications to meet the increasing demand for customization at the time. It provided the basic facilities of most procedural programming languages, but more complicated or domain-specific features were not included; rather, it included mechanisms for extending the language, allowing programmers to implement such features. As Lua was intended to be a general embeddable extension language, the designers of Lua focused on improving its speed, portability, extensibility and ease-of-use in development.
Lua originated in 1993 as a language for extending software applications to meet the increasing demand for customization at the time. It provided the basic facilities of most procedural programming languages, but more complicated or domain-specific features were not included; rather, it included mechanisms for extending the language, allowing programmers to implement such features. As Lua was intended to be a general embeddable extension language, the designers of Lua focused on improving its speed, portability, extensibility and ease-of-use in development.
== WoW Lua ==
By the release of 3.3.5a, Blizzard had made various helpful modifications to its version of Lua.
=== Taint ===
In WoW Lua, each variable contains a taint value, a string that identifies the AddOn from where the variable originated.
=== Profiling ===
Because each variable is taint-tagged by whichever AddOn generated it, WoW Lua is able to compute the memory usage of any particular AddOn.
<pre>
void  lua_gcupdatesizes(lua_State* L);
lu_mem lua_gcgetsize(lua_State* L, const char* tag);
</pre>
Optionally, function performance can be profiled by turning on a flag (which is governed by the <code>scriptProfile</code> CVar).
You can read the results of the function profiler with:
<pre>
void      lua_gcupdatetimes(lua_State* L);
lua_Number lua_gcgettime(lua_State* L, const char* tag);
void      lua_gcgetfunctiontime(lua_State* L, lua_Number* flat, lua_Number* total, int32_t* ncalls);
void      lua_gcresettimes(lua_State* L);
</pre>
=== Standard library ===
WoW Lua modifies the standard library by removing functions that expose the host filesystem, modifying existing functions, or adding new ones.
These functions were removed from the standard library:
* <code>dofile()</code>, <code>loadfile()</code> - Removed to prevent Lua from touching the host filesystem.
* <code>load()</code> - Reason for removal unclear
* <code>print()</code> - Removed to prevent Lua from touching stdout. This is replaced by a function that prints output to the ingame chat.
* <code>math.randomseed()</code>
* <code>string.sub()</code>
These existing standard library functions were modified:
* <code>getfenv()</code> - Implementation adds this code to end of function: <code>luaL_getmetafield(L, -1, "__environment");</code>
* <code>string.upper()</code>, <code>string.lower()</code> - These were modified to support UTF-8 strings. Unlike stock Lua, they are able to convert special characters including Latin-1 and Cyrillic.
These standard library functions were added by Blizzard:
* <code>table.removemulti()</code>
* <code>table.wipe()</code>