lua-users home
lua-l archive

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

At the moment, the functions pairs and ipairs do just what they're
named. But the metamethods __pairs and __ipairs will generalize this so
any table or userdata will be iterable in a standard way. Except,
there's no reason why an iterator should be returning a "pair", is
there? A relational DB cursor, when iterated, would return the
columns for each row. That could be any number of values, depending on
the query.

If the names remain "pairs" and "ipairs" in 5.2, it would be an
anachronism, wouldn't it? Could a more appropriate name be adopted when
the new metamethods are added? So future code will be more readable.

Possible alternatives are "iter", "iterator", "each", "items",
"enumerate" (for ipairs).

-- tom