lua-users home
lua-l archive

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


On Sep 4, 2013, at 3:25 PM, Ousmane Roland Yonaba <roland.yonaba@gmail.com> wrote:

> Since Lua 5.1, table.foreach and table.foreach were deprecated[1].
> It is known (I am such a fan of Game Of Thrones... :)).
> 
> I would just like to know why. Are there good reasons to this ?
> I bet there are, as looking at the evolution of Lua, nothing is seems
> to be done without some solid motives at the basis.
> 
> But to me, this syntax was so much beautiful:
> 
>    table.foreach({...}, print)
> 
> It misses me under Lua 5.2.x.
> Well, I am not saying I want it back. Just looking for...reasons.
> Thanks reading.
> 
> Regards,
> Roland Y.
> 
> [1] http://www.lua.org/manual/5.1/manual.html#7.2
> 

It's pretty easy to add it back in with a few lines of Lua code…

-- NOT TESTED
function tableForEach(t, f)
	for _, v in pairs(t) do f(v) end
end

There are endless variations of course.

--Tim