lua-users home
lua-l archive

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


On Sun, 14 Feb 2021 at 12:36, Lorenzo Donati <lorenzodonatibz@tiscali.it> wrote:
Hi folks!

Trying to spare a little time here.

I'm writing a little library for my stuff which will make use of Lua 5.3
table.move but should also be usable with Lua 5.1.

I could write an ad-hoc Lua 5.1-compatible fallback function, but I'd
prefer not to waste time reinventing the wheel (and thoroughly testing
it with all corner cases)!

So I thought that maybe a /well-tested/ /pure-Lua/ replacement for
table.move has already been posted somewhere that I could copy-paste
into my code.

I don't care if it is a bit slow (as long as it is not utterly
wasteful), but it should be well tested and/or "peer-reviewed" and
should replicate table.move semantics in the details (I wouldn't want
unexpected differences between Lua 5.3 and Lua 5.1 scripts).

Any pointers appreciated.

What you're looking for is the compat-5.3 library:

https://github.com/keplerproject/lua-compat-5.3

It includes based implementations of many compatibility functions for performance but many functions (including table.move) have pure-Lua fallbacks. If you're using LuaRocks, including compat53 as a dependency and a `require "compat53"` in your project is sufficient (it is a no-op in Lua 5.3+), no need to resort to copy-pasting.

-- Hisham