[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Call to __len metamethod has userdata/table twice on stack
- From: nobody <nobody+lua-list@...>
- Date: Thu, 16 Feb 2017 22:48:24 +0100
On 2017-02-16 22:28, email@example.com wrote:
> I came across an odd behaviour where the call to a __len function has
> 2 identical stack items.
All unary metamethods may receive a second dummy argument. That's
expected (and also somewhere in the refman IIRC).
> I also tested __tostring and it does have only one item.
__tostring isn't a "real" metamethod (not core-defined but
function-defined, `tostring()` just happens to check for that field in a
metatable & use it), so it doesn't show this behavior.