+ Reply to Thread
Results 1 to 6 of 6

Thread: Daily Error report - fixed, but WTH?

  1. #1
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default Daily Error report - fixed, but WTH?

    I got an error for my old CallbackHandler port, and along the way, found a bug with LibStub. Both are fixed, but there is one "bug" I had to fix which I do not think should be a bug.
    Code:
    Error: LibCallbackHandler/LibCallbackHandler.lua:5: unexpected symbol near '.'
        In LibCallbackHandler / LibCallbackHandler.lua
    The offending lines are upvalued code:
    Code:
    -- Lua APIs
    local table.concat = table.concat -- this is the offending line. once commented, no problems!
    local assert, error, loadstring = assert, error, loadstring
    local setmetatable, rawset, rawget = setmetatable, rawset, rawget
    local next, select, pairs, type, tostring = next, select, pairs, type, tostring
    Why does every other upvalued API work as intended, but not table.concat? Seems silly to me.

  2. #2
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    you cannot declare a local "table.concat", you need a local "table" table first before you can assign it members. "table.concat" is usually upvalued as "tconcat" because of this.

  3. #3
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    Quote Originally Posted by Imhothar View Post
    you cannot declare a local "table.concat", you need a local "table" table first before you can assign it members. "table.concat" is usually upvalued as "tconcat" because of this.
    Good to know. Strange (to me anyway) that it works as-is in WoW, but has to be changed to your suggested method in Rift. The table.* functions are Lua-neutral, and not game dependent.

  4. #4
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Quote Originally Posted by Lorandii View Post
    Good to know. Strange (to me anyway) that it works as-is in WoW, but has to be changed to your suggested method in Rift. The table.* functions are Lua-neutral, and not game dependent.
    That's not the point. The "local" in front is the problem, that is illegal syntax. I'm sure it doesn't compile in WoW either as both use the Lua 5.1 frontend.

    As per Lua syntax local must be followed by a namelist. A namelist is defined as a coma-separated list of Names and a Name is an identifier like abc. But table.concat is syntactic sugar for table["concat"] which is an expression, so what you are trying to do is
    Code:
    local table["concat"] = table.concat
    That just looks wrong

    You can look this up in chapter 2 of the Lua 5.1 Reference Manual

    What you are basically trying to do is create a local table AND give it a member concat in one expression, which is not possible as a local statement. If you removed the local and wrote
    Code:
    table.concat = table.concat
    it becomes a no-op.

    I think what you intended to do was:
    Code:
    local table = { concat = table.concat }
    So in fact, if that compiles in WoW it is wrong there and correct in Rift.

  5. #5
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    Edit: Imho beat me to the reply

    It's really odd that that works in WoW tbh. You can't declare a table member as local - either the *table* is local or not, members of a table can't be declared as local (they are scoped to the table).

    Ie, even if 'mytable' already exists...

    Code:
    local mytable.myvalue = 10
    ... is always invalid Lua.

    To do what you want, you could use:

    Code:
    local table = table
    but a call to table.concat would still require an index lookup into the local table, so creating a tconcat local would still be best performance-wise.
    Last edited by DoomSprout; 06-27-2012 at 02:50 AM.

    Gadgets: Unit Frames and Other Stuff for RIFT

  6. #6
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    Imhothar & DoomSprout, thank you for the replies. You learn something new each day, as the expression goes. Funny that Rift catches a bug that WoW lets slip. Yep, I admit it was a bug in my code in the first place, but since I've never been hit with it before, that explains why I didn't know.

    Again, thank you to both of you.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts