When was the __pairs metamethod introduced?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

When was the __pairs metamethod introduced?

Marc Balmer
Wasn't the __pairs metamethod first available in Lua 5.2?  It is not mentioned here: http://www.lua.org/manual/5.2/manual.html#8.3 Are such changes generally not listed?

- mb

Reply | Threaded
Open this post in threaded view
|

Re: When was the __pairs metamethod introduced?

Luiz Henrique de Figueiredo
> Wasn't the __pairs metamethod first available in Lua 5.2?  It is not mentioned here: http://www.lua.org/manual/5.2/manual.html#8.3 <http://www.lua.org/manual/5.2/manual.html#8.3> Are such changes generally not listed?

It's listed in http://www.lua.org/manual/5.2/readme.html#changes .

Reply | Threaded
Open this post in threaded view
|

Re: When was the __pairs metamethod introduced?

Marc Balmer

> Am 12.04.2016 um 13:45 schrieb Luiz Henrique de Figueiredo <[hidden email]>:
>
>> Wasn't the __pairs metamethod first available in Lua 5.2?  It is not mentioned here: http://www.lua.org/manual/5.2/manual.html#8.3 <http://www.lua.org/manual/5.2/manual.html#8.3> Are such changes generally not listed?
>
> It's listed in http://www.lua.org/manual/5.2/readme.html#changes .
>

Oh, I see. So there is __ipairs, too. Maybe that could be noted in the doc as well, http://www.lua.org/manual/5.3/manual.html#pdf-ipairs does not mention it, while http://www.lua.org/manual/5.3/manual.html#pdf-pairs does.


Reply | Threaded
Open this post in threaded view
|

Re: When was the __pairs metamethod introduced?

Luiz Henrique de Figueiredo
> Oh, I see. So there is __ipairs, too. Maybe that could be noted in the doc as well, http://www.lua.org/manual/5.3/manual.html#pdf-ipairs does not mention it, while http://www.lua.org/manual/5.3/manual.html#pdf-pairs does.

In Lua 5.3, there is no __ipairs, though it is present for compatibility.

http://www.lua.org/manual/5.3/readme.html#changes says:

        Libraries
        - ipairs and the table library respect metamethods

Reply | Threaded
Open this post in threaded view
|

Re: When was the __pairs metamethod introduced?

Marc Balmer

> Am 12.04.2016 um 14:05 schrieb Luiz Henrique de Figueiredo <[hidden email]>:
>
>> Oh, I see. So there is __ipairs, too. Maybe that could be noted in the doc as well, http://www.lua.org/manual/5.3/manual.html#pdf-ipairs does not mention it, while http://www.lua.org/manual/5.3/manual.html#pdf-pairs does.
>
> In Lua 5.3, there is no __ipairs, though it is present for compatibility.
>
> http://www.lua.org/manual/5.3/readme.html#changes says:
>
> Libraries
> - ipairs and the table library respect metamethods
>


I see.  Will the __ipairs metamethod eventually be removed?  Should it be avoided in new code?  Is the way to go to implement __pairs, __index, and, __newindex?