lua-users home
lua-l archive

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


You know John... I like it.

Not that it matters much, but for what it's worth, you've won me over. Here's what I think you're saying:

Tables are Lua's only structures. It stands to reason that they are the only thing that *could* be iterated, except numbers. Therefore, providing a generalized mechanism for them to store their own method of iteration makes sense.

In fact, I'll go further and say that it makes more sense than does over-riding ipairs/pairs. I think what you are saying is that:

"for looks for an iterator followed by a table or a table with an iterator metamethod, which takes:

for k, v in t do...

and expands it to...

for k, v in getmetatable(t).__iter, t do" 

now that just seems darn right.

__iter might have some historical or other fantastic reason. To my ignorant thinking "__next" seems logical, as well and blends well with the core language and actually seems to be a logical extension of having __ipairs and __pairs in there. In fact, it seems more generic, to me, at least. I'm expecting that I'm missing something here, however.