lua-users home
lua-l archive

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


On Wed, Jun 10, 2009 at 12:57 PM, John Hind<john.hind@zen.co.uk> wrote:
> If this were a democracy (which it isn't probably explaining why we do not
> have a 'Swiss Army Chainsaw'), I'd vote for a '__iter' metamethod so you
> could provide a customised iterator factory for an object class. This would
> allow syntax:
>
> for k,v in obj do ... end
>
> rather than the present (and in my no doubt controversial view, ugly and
> error-prone):

I've missed that since 5.0, but I understand the rationale, in the
_absence_ of __iter!

I've found myself wishing I could iterate over my list objects with
'for v in l do..end', which would be a piece of cake with __iter.

steve d.

PS. An excellent comment on our gentle dictatorship. Gave me a laugh:

http://lua-users.org/lists/lua-l/2009-03/msg00202.html