lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2013/4/25 Andrew Starks <andrew.starks@trms.com>:

> a = function(arg1 = 3, arg2 = {"first value", x = d, } or old_value or
> error("arg2 is required"))

Just to clarify: my original intention was not to provide keyword arguments,
but to provide compile-time default values. For example:

function claim(condition,message="Warning",log=io.stderr)
   if not condition then log:write(where(2),message,'\n') end
end

which might be called as

claim(x>0)
claim(x>0,"This will only work if x>0")
claim(x>0,nil,mylogfile)
claim(nil,"Header for default error log")

And I have by now got an answer: people prefer `=` over `or`.