lua-users home
lua-l archive

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


On Fri, Sep 11, 2009 at 12:03 PM, John Hind <john.hind@zen.co.uk> wrote:
> On the other hand, using the "__call" metamethod you CAN write:
>
> for v in myobject do print(v) end
>
> without the empty parenthesis, which seems inconsistent since both cases are
> ultimately just function calls.

Yes, because myobject is callable.  But myobject:iter() _returns_ a
callable, usually a closure that contains iterator state.

That's the difference.

PS, I do agree that __ipairs and __pairs seems silly.

steve d.