[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: ipairs in Lua 5.3.0-alpha
- From: Sean Conner <sean@...>
- Date: Tue, 19 Aug 2014 12:45:24 -0400
It was thus said that the Great Dirk Laurie once stated:
>
> My conceptual objection is that the base library should not be
> targeted to the special needs of people who need metamethods
> to the point of inconveniencing those who do not. That stuff
> can go into the table library, which has a long history of being
> misunderstood if not disliked by many and seems destined
> to continue in that great tradition.
I rely upon metamethods. A lot. But not on tables. I use a ton of
userdata objects in my code (5.1, mainly to keep the ability to use LuaJIT
if I have to at work). Putting this stuff into the table library won't be
of much use to me.
Now, __pairs or __ipairs don't exist in Lua 5.1 and of the two, I regret
not having __pairs. I can work around __ipairs with
for i = 1 , #userdata do ... end
__pairs, not so much [1].
-spc
[1] Okay, I can work around it with a very clumsy:
udindex = { 'foo' , 'bar' , 'baz' }
for _,idx in ipairs(udindex) do
local item = userdata[idx]
...
end