lua-users home
lua-l archive

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

On Nov 25, 2013, at 7:24 AM, John Hind <> wrote:

1) Iterating over a linked list (__ipairs can cache the current node)
2) Where the data for t[i] is accessed over a network (__ipairs can
fetch it in bulk because it knows it's iterating)

These are certainly good cases for specialised iterators, but why implement them by hijacking 'ipairs'? Again, write your own iterator factory and call it something appropriate.

… because ipairs() is implicitly designed for hijacking … using __ipairs(). And this allows the creation of generic code more easily than iterator factories for those who are less experienced in OO (re: many users of Lua). I think both examples are valid.