|
Asko Kauppi wrote:
..following a rather ancient thread on this list..A quick 'grep' of Lua 5.1w4 sources reveals that the '__pairs' metamethod is not in, at least, not yet. Has that plan been trashed for some reason, since I feel it would suit pretty nicely in the Lua ideology.My issue: making a "table emulating" userdata _really_ behave like a table, also when it comes to iteration. Of course, I could redefine 'pairs'.. hmm.. ;)
Closely related: I just had a problem with ipairs. The table in question emulates an indexed array via __index and __newindex calls that get the desired data from another location. Unfortunately, the built-in implementation of ipairs calls rawget and sees that there's nothing there, so no iteration happens.
So my feature request of the day is one of two alternatives:(1) Rewrite the built-in implementation of ipairs to use get instead of rawget.
(2) Add an __ipairs metamethod similar to the __pairs method that's been discussed.
-Eric