lua-users home
lua-l archive

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


On Tue, Jun 28, 2016 at 8:07 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 1. If the __index metamethod exists, use it.
> 2. If not, use tbl["#"] as the length.
> 3. If that is nil or false, revert to the built-in algorithm.

Assume that '__len' is meant, not '__index'

Why not simply leave out (2)?  Imagine having to explain how #t works
in a future manual.

However, I'm all for table.pack() returning a table which has a
metatable with __len = self.n, and table.unpack() respecting this.