[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [PATCH] setmetatable({}) causes error
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 13 Jul 2017 13:12:28 -0300
> > The authoritative answer is given by the manual which says
>
> > setmetatable (table, metatable)
> > http://www.lua.org/manual/5.3/manual.html#pdf-setmetatable
>
> > Note that the second argument must be present. It is not marked as
> optional.
>
> This semantics is incompatible with section 3.4.11, which says:
>
> When a function is called, the list of arguments is adjusted to the length
> of the list of parameters, unless the function is a *vararg function*,
> which is indicated by three dots ('...') at the end of its parameter list.
This whole explanation, as you said, is in Section 3.4.11, which is
all about functions defined in Lua. I hope you do not expect that
the previous sentence ("Parameters act as local variables that are
initialized with the argument values") applies also to C functions.
Similarly for the next sentence ("A vararg function [...] collects all
extra arguments and supplies them to the function through a vararg
expression"). So, I see no reason to expect that this particular
sentence would apply to C functions. But we can pretend this was the
source of the problem and try to make that text more clear.
-- Roberto