1. Hello lua dwellers:

    If this two definitions are wrong/inconsistent plz don't bash me a hammer, I make many mistakes so tips are appreciated:

    D1 - First of all I will call Named Arguments the ability of a function to have it's arguments parsed in any order and properly assert them.

    D2 - Second definition, an optional argument is as it name refers a value that can be omitted.

    So let the discussion begin:

    Topic1 - How does the WoW API manages Named and Optional Arguments?.

    T2 - How does a wow-lua-coder should build a function with Named Arguments?. (Consider the very different cases even the obvious ones).

    T3 - How does a wow-lua-coder should build a function with Optional Arguments?. (Consider the very different cases even the obvious ones).

    According to PIL (programing in lua) doc:

    http://www.lua.org/pil/5.3.html

    Sometimes, however, it is useful to specify the arguments by name. To illustrate this point, let us consider the function rename (from the os library), which renames a file. Quite often, we forget which name comes first, the new or the old; therefore, we may want to redefine this function to receive its two arguments by name: -- invalid code

    rename(old="temp.lua", new="temp1.lua")
    Lua has no direct support for that syntax, but we can have the same final effect, with a small syntax change. The idea here is to pack all arguments into a table and use that table as the only argument to the function. The special syntax that Lua provides for function calls, with just one table constructor as argument, helps the trick:
    rename{old="temp.lua", new="temp1.lua"}
    Accordingly, we define rename with only one parameter and get the actual arguments from this parameter: function rename (arg)
    return os.rename(arg.old, arg.new)
    end
    

    Wich in short suggest to fix the issue with table a implementation; I just hope there is a better workaround. Also PIL generally refers to some un-updated practices.

    Ty.

    Hello lua dwellers:

    If this two definitions are wrong/inconsistent plz don't bash me a hammer, I make many mistakes so tips are appreciated:

    D1 - First of all I will call Named Arguments the ability of a function to have it's arguments parsed in any order and properly assert them.

    I'm not quite sure that I understand this definition, but okay.

    D2 - Second definition, an optional argument is as it name refers a value that can be omitted.

    Okay.

    So let the discussion begin:

    Topic1 - How does the WoW API manages Named and Optional Arguments?.

    The same way the Lua API handles optional arguments (I have NO idea what you mean by named arguments, they're just arguments). For example, consider table.insert(), which has an optional second argument.

     tbl = {}
     table.insert(tbl, "alpha")
     table.insert(tbl, "beta")
     table.insert(tbl, "delta")
     table.insert(tbl, 3, "gamma")
     print(unpack(tbl))
    

    The third call to table.insert() uses the optional argument to specify the position at which to insert the element. Not sure what more information you're looking for.

    T2 - How does a wow-lua-coder should build a function with Named Arguments?. (Consider the very different cases even the obvious ones).

    I don't understand named arguments. You just write functions, as covered in the chapter.

    T3 - How does a wow-lua-coder should build a function with Optional Arguments?. (Consider the very different cases even the obvious ones).

    You don't unless you have an incredibly good reason to (you don't). They require runtime error checking and they're not very nice.

    According to PIL (programing in lua) doc:

    http://www.lua.org/pil/5.3.html

    Sometimes, however, it is useful to specify the arguments by name. To illustrate this point, let us consider the function rename (from the os library), which renames a file. Quite often, we forget which name comes first, the new or the old; therefore, we may want to redefine this function to receive its two arguments by name: -- invalid code

    rename(old="temp.lua", new="temp1.lua")
    Lua has no direct support for that syntax, but we can have the same final effect, with a small syntax change. The idea here is to pack all arguments into a table and use that table as the only argument to the function. The special syntax that Lua provides for function calls, with just one table constructor as argument, helps the trick:
    rename{old="temp.lua", new="temp1.lua"}
    Accordingly, we define rename with only one parameter and get the actual arguments from this parameter: function rename (arg)
    return os.rename(arg.old, arg.new)
    end
    

    Wich in short suggest to fix the issue with table a implementation; I just hope there is a better workaround. Also PIL generally refers to some un-updated practices.

    I really don't understand what you're asking here. What are you concerned with?