Lua 5.1

#0 - Aug. 30, 2006, 11:53 p.m.
Blizzard Post
WoW will be using Lua 5.1 for the expansion.

For the most part, this is a seamless transition, but there is one syntax change that will need to be made in a lot of addons:
for k,v in table do stuff end
changes to:
for k,v in pairs(table) do stuff end

Also, the main advantage of Lua 5.1 is the incremental garbage collection, and the full functionality of the 5.1 collectgarbage() function is available to the WoW scripting system.
#28 - Aug. 31, 2006, 6:25 p.m.
Blizzard Post
You can use the new "pairs(table)" semantic now, by the way. :)
#38 - Aug. 31, 2006, 11:03 p.m.
Blizzard Post
WoW Lua 5.1 is currently compiled with these options:

#define LUAI_GCPAUSE 200
#define LUAI_GCMUL 200
#undef LUA_COMPAT_GETN
#undef LUA_COMPAT_VARARG
#undef LUA_COMPAT_MOD
#undef LUA_COMPAT_LSTR
#undef LUA_COMPAT_GFIND

There are also these changes:
Added difftime()
Added gmatch() as an alias for str.gmatch()
Added strmatch as an alias for str.match()
Added strrev() as an alias for str.reverse()
The alias mod() now maps to math.fmod()
#41 - Aug. 31, 2006, 11:18 p.m.
Blizzard Post
This construct:
function foo(...) for i=1, arg.n do local v = arg[i] end end
should be changed to:
function foo(...) for i=1, select("#", ...) do local v = select(i, ...) end end
#52 - Sept. 1, 2006, 2:47 a.m.
Blizzard Post
*laugh* Okay, between the three of us, I think we got it right.
#67 - Sept. 2, 2006, 7:50 a.m.
Blizzard Post
Q u o t e:

  • There is also a subtlety in the way that the new "select" function works, that is a bit obscure in the documentation.

    function f (...)
    print (select (2, ...))
    end -- f

    f (22, 33, 44) --> 33 44

    Note the output of both 33 and 44, as the select function returns from the nominated argument onwards. The examples given earlier obscure this point a bit because they are assigning to a single variable, eg.

    local v = select(i, ...) --> assigns to v, discards extra results


  • [/ul]


    This is actually a neat trick, and allows you to do things like:

    function foo(a, ...)
    for i=1, select(#, ...), 3 do
    local r, g, b = select(i, ...);
    something colorful
    end
    end
    #72 - Sept. 3, 2006, 3:27 p.m.
    Blizzard Post
    FYI, the game already does garbage collection when zoning. :)
    #86 - Jan. 24, 2009, 11:32 p.m.
    Blizzard Post
    Your post isn't relevant to this thread, because this thread is no longer relevant to anything.

    Please post a new thread if you wish to start a discussion!