lua-users home
lua-l archive

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


On 2017-02-16 22:28, tobias@justdreams.de wrote:
> Hi,
> 
> 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.

-- nobody