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:
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.
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
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:
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)