lua-users home
lua-l archive

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


On Mon, Nov 25, 2013 at 5:24 PM, John Hind <john.hind@zen.co.uk> wrote:
> for element in list do
>
> This works because 'list' has a metatable which supplies the appropriate iterator factory for tables specialised as lists.

I do think __iter is a good candidate for a new metamethod. Penlight
'lists' have an iter() method which I tend to use fairly often, even
though I _know_ it's not that efficient.  (Moonscript has 'for x in
*t' which expands to the fast but ugly explicit loop)