lua-users home
lua-l archive

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


> 2014-08-19 18:48 GMT+02:00 Dirk Laurie <dirk.laurie@gmail.com>:
> > Roberto's most recent idea [1], which has received only approval so
> > far, is to let the iteration still bail out, like the raw-access ipairs did,
> > when the value is nil. If you want that to be the only way of stopping,
> > __len can simply return math.maxinteger.
> 
> Oops, did not read that properly. The idea says "first nil after #t"
> so you need __len to return 0 to iterate to the first actual nil. This
> is not the idea that I and others have applauded :-(

I think it could be: Go until #t. If there is no __len metamethod,
assume the table is a proper sequence and stop at the first nil (which
should correspond to #t anyway).

-- Roberto