lua-users home
lua-l archive

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

John Belmonte wrote:
> Philippe Lhoste wrote:
> > Sorry if I don't answer correctly to your request, but I believe Lua
> already
> > have a mechanism for this.
> >
> > foreach (table, func)
> > foreachi (table, func)
> Sorry, I should have addressed these library functions in my post.  Well, if
> foreach() is so great, why do we have a special for construct to do the same
> thing?  Remember that the for command was created after these functions
> already existed.  I'll bet that since for loops were introduced as a way to
> iterate tables, most of us don't use foreach() anymore.  Having to create
> function objects can sometimes make code hard to follow.   So since there is
> a form of for matching foreach(), why not foreachi() too?

And while we're at it, I'd really love a "next" tag method (maybe also
"nexti") that allows the construction of generic iterators for user
types. A for/foreach function should then use the respective tag


Adolf Mathias              EMail: dolfi at zkm dot de  Web:
|||| / |< |||                 ZKM Basic Research - Grundlagenforschung
P.B. 6919 D-76049 Karlsruhe, Germany; fon +49 721-8100-1511, fax -1509