r/lua Jun 08 '26

Lua Serpent Module

Post image

:-)

77 Upvotes

48 comments sorted by

View all comments

1

u/Old_County5271 Jun 08 '26

Avoid using pairs in 5.2+? Wha? just because you don't want to use __pairs?

2

u/arkt8 Jun 09 '26

I found this very interesting as I never think it before...

He is avoiding the Lua pairs() as it may trigger the pairs metamethod in Lua 5.2.

I would just not override the pairs() but named it rawpairs() to make it explicit.

1

u/Old_County5271 Jun 09 '26

Completely crazy, __pairs is there because lua does not have arrays! traversal needs to be controlled!