This manual uses the following conventions:
func(arg1=val1, arg2=val, arg3=val3)
arg
=val
means that
parameter arg
is optional, and function receives
value val
if it's missing. Not all parameters are necessarily
optional. For example, insert_text(text, where=nil)means that
text
may not be missing or nil
(unless documentation says otherwise), and where
is optional.
func{arg1, arg2, kwarg1=kwval1, kwarg2=kwval2}This means that function can be called in an alternative way: actual parameters are taken from the single table parameter, which must be a dictionary with keys
kwarg1
, kwarg2
, etc., and whose array part
must contain exactly as many values as there are non-optional arguments. Similarly
to regular parameters, kwarg
=kwval
means that
kwarg
is optional. For example, above function can be called
as follows.
func{1, 2, kwarg1='foo'} -- equivalent to func(1, 2, 'foo') func{3, 4, kwarg2='bar'} -- equivalent to func(3, 4, kwval1, 'bar') func{5, 6, kwarg2='baz', kwarg1='bud', } -- equivalent to func(5, 6, 'bud', 'baz')This is similar to Python keyword arguments (with the difference that keyword arguments may be used only if function is documented to support them).