lua-users home
lua-l archive

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


On Wed, May 26, 2010 at 11:34 AM, phlnc8 <phlnc8@gmail.com> wrote:
>
> A very frequent case is iterating over a list without using the integer index.
> Would it make sense in this case to use the following form:
>
>  for x in t do ...
>

This could be as well extended to pairs():

  for x in t do ...    -- equivalent to:   for _,x in ipairs(t) do ...
  for k,x in t do ... -- equivalent to:   for k,x in pairs(t) do ...

The compiler knows how to differentiate forms by looking at the number
of variables.

What would be lost then is general iteration forms such as:
  for a,b,c,d,e in some_iterator_returning_five_values() do ...

Is that frequent?


Phil