How To: Lua named arguments

Several programming languages let you create functions with named parameters called arguments. Named arguments are basically arguments that you can target using a name. As an example, in C# you can write this: ...but you can also write it like this:

By naming arguments, you improve readability. It also gives you more freedom as you're not forced to write arguments in a specific order and you may even leave arguments out (if they're marked as "optional".)

Named arguments in Lua
Lua doesn't offer such a system directly. However, you can use a table to apply this technique. In LunaLua there are several functions which accept named arguments. The signature for those functions are always the same:

To call this function you can write this: ...or you can use an alternative order: In this example  can accept named arguments:
 * (A string value)
 * (A number value)
 * (A number value [Optional value] )

You probably noticed that there are no parentheses used to call the function. If you only have one argument, and it's a table or string literal, the parentheses are optional.