lua-users home
lua-l archive

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


[written in Outlook Express.  :-P ]

"John Belmonte" <jvb@prairienet.org> writes:
> Jay Carlson wrote:
> > I'm getting tired of typing
> >
> > for i=1,getn(l) do
> >   local v=l[i]
> >   [...]
> > end
> >
> > It makes the loop look more complicated than it is, harder to
> > understand at first glance etc.  What I'd like is something like
> >
> > for i,v in list l do
> >   [...]
> > end
>
> A while back I made a small patch for 4.0 that takes care of this (see
Power
> Patches page on the Lua Wiki).  However my patch doesn't provide the index
> value.  Edgar T's Sol provides exactly what you wrote but you may have a
> hard time picking out the necessary changes.

Cool.  I usually don't use the index value either.  But it seemed best to
keep the symmetry with the existing for-in table syntax, and use _,v to
throw away when necessary.

I looked at sol a little a while ago; I was impressed.  I'm a little worried
about how far it is away from straight lua, but that's more a
political/social issue than a technical concern.

Jay