lua-users home
lua-l archive

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


2015-06-17 20:11 GMT+02:00 Brigham Toskin <brighamtoskin@gmail.com>:
> On Tue, Jun 16, 2015 at 6:57 PM, 书呆彭, Peng Yi <nerditation@outlook.com>
> wrote:
>> meta-method in Lua is not a mechanism to override but as a fallback.
> __len() would disagree.

Basically Peng Yi is correct. __len was a very late addition to Lua (5.2)
and is the only example of a core ability depending on a metamethod.

Fallbacks date back to Lua 2.1. They became "tag methods" in Lua 3.0 and
metamethods in 5.0. There was some semantic reason each time for the
name change, but for __add, __eq and friends, a metamethod remains
something that is only invoked when Lua does not know what to do.