lua-users home
lua-l archive

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


I agree - the dual nature of the table type precludes setting a metatable by
default (like was recently done for string). Some layer on top of base Lua
has to decide if a particular table should use pairs, ipairs or something
else (and attach the appropriate metatable).

> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> bounces@bazar2.conectiva.com.br] On Behalf Of Alexander Gladysh
> Sent: 16 December 2009 22:04
> To: Lua list
> Subject: Re: '__iter', yet again!
> 
> On Thu, Dec 17, 2009 at 00:29, John Hind <john.hind@zen.co.uk> wrote:
> > '__iter' is intended to enable you to write:
> 
> > for v in obj do ... end
> 
> Oh. I hope, if such feature would be implemented, default __iter would
> not be set for any Lua type.
> 
> Another option I can live with, is to make third kind of for loop for
> this.
> 
> I prefer to be explicit in my loops.
> 
> Alexander.